stage2: LLVM backend: implement @tagName for enums
Introduced a new AIR instruction: `tag_name`. Reasons to do this instead of lowering it in Sema to a switch, function call, array lookup, or if-else tower: * Sema is a bottleneck; do less work in Sema whenever possible. * If any optimization passes run, and the operand to becomes comptime-known, then it could change to have a comptime result value instead of lowering to a function or array or something which would then have to be garbage-collected. * Backends may want to choose to use a function and a switch branch, or they may want to use a different strategy. Codegen for `@tagName` is implemented for the LLVM backend but not any others yet. Introduced some new `Type` tags: * `const_slice_u8_sentinel_0` * `manyptr_const_u8_sentinel_0` The motivation for this was to make typeof() on the tag_name AIR instruction non-allocating. A bunch more enum tests are passing now.
This commit is contained in:
@@ -785,8 +785,23 @@ pub const Builder = opaque {
|
||||
|
||||
pub const buildExactSDiv = LLVMBuildExactSDiv;
|
||||
extern fn LLVMBuildExactSDiv(*const Builder, LHS: *const Value, RHS: *const Value, Name: [*:0]const u8) *const Value;
|
||||
|
||||
pub const zigSetCurrentDebugLocation = ZigLLVMSetCurrentDebugLocation;
|
||||
extern fn ZigLLVMSetCurrentDebugLocation(builder: *const Builder, line: c_int, column: c_int, scope: *DIScope) void;
|
||||
|
||||
pub const clearCurrentDebugLocation = ZigLLVMClearCurrentDebugLocation;
|
||||
extern fn ZigLLVMClearCurrentDebugLocation(builder: *const Builder) void;
|
||||
|
||||
pub const getCurrentDebugLocation2 = LLVMGetCurrentDebugLocation2;
|
||||
extern fn LLVMGetCurrentDebugLocation2(Builder: *const Builder) *Metadata;
|
||||
|
||||
pub const setCurrentDebugLocation2 = LLVMSetCurrentDebugLocation2;
|
||||
extern fn LLVMSetCurrentDebugLocation2(Builder: *const Builder, Loc: *Metadata) void;
|
||||
};
|
||||
|
||||
pub const DIScope = opaque {};
|
||||
pub const Metadata = opaque {};
|
||||
|
||||
pub const IntPredicate = enum(c_uint) {
|
||||
EQ = 32,
|
||||
NE = 33,
|
||||
|
||||
Reference in New Issue
Block a user