Skip to content

Conversation

@tienex
Copy link

@tienex tienex commented Nov 27, 2025

This commit adds a new LLVM IR backend to the Portable C Compiler (PCC). The backend generates LLVM intermediate representation instead of native assembly code.

Changes:

  • Created arch/llvm/ directory with all required backend files
  • Added macdefs.h with LLVM type definitions (64-bit target)
  • Implemented code.c for Pass 1 LLVM IR output generation
  • Implemented local.c with Pass 1 utility functions
  • Implemented local2.c for Pass 2 LLVM IR code generation
  • Added table.c with minimal instruction matching table
  • Implemented order.c for instruction ordering
  • Updated configure.ac to recognize 'llvm' as a target CPU

The backend uses virtual registers and generates LLVM IR instructions through the zzzcode() mechanism. It supports basic operations including:

  • Arithmetic operations (add, sub, mul, div, mod)
  • Bitwise operations (and, or, xor)
  • Shift operations
  • Comparison operations
  • Floating point operations
  • Function calls

To use: configure with --target=llvm-linux-gnu or similar

🤖 Generated with Claude Code

This commit adds a new LLVM IR backend to the Portable C Compiler (PCC).
The backend generates LLVM intermediate representation instead of native
assembly code.

Changes:
- Created arch/llvm/ directory with all required backend files
- Added macdefs.h with LLVM type definitions (64-bit target)
- Implemented code.c for Pass 1 LLVM IR output generation
- Implemented local.c with Pass 1 utility functions
- Implemented local2.c for Pass 2 LLVM IR code generation
- Added table.c with minimal instruction matching table
- Implemented order.c for instruction ordering
- Updated configure.ac to recognize 'llvm' as a target CPU

The backend uses virtual registers and generates LLVM IR instructions
through the zzzcode() mechanism. It supports basic operations including:
- Arithmetic operations (add, sub, mul, div, mod)
- Bitwise operations (and, or, xor)
- Shift operations
- Comparison operations
- Floating point operations
- Function calls

To use: configure with --target=llvm-linux-gnu or similar

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants