mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
llvm.Builder: add !nosanitize API
see #20992 Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
This commit is contained in:
parent
61919fe63d
commit
26d5c27ba0
2 changed files with 319 additions and 111 deletions
|
|
@ -3994,6 +3994,7 @@ pub const Function = struct {
|
||||||
names: [*]const String = &[0]String{},
|
names: [*]const String = &[0]String{},
|
||||||
value_indices: [*]const u32 = &[0]u32{},
|
value_indices: [*]const u32 = &[0]u32{},
|
||||||
strip: bool,
|
strip: bool,
|
||||||
|
any_nosanitize: bool,
|
||||||
debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{},
|
debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{},
|
||||||
debug_values: []const Instruction.Index = &.{},
|
debug_values: []const Instruction.Index = &.{},
|
||||||
extra: []const u32 = &.{},
|
extra: []const u32 = &.{},
|
||||||
|
|
@ -4090,6 +4091,7 @@ pub const Function = struct {
|
||||||
block,
|
block,
|
||||||
br,
|
br,
|
||||||
br_cond,
|
br_cond,
|
||||||
|
br_cond_nosanitize,
|
||||||
call,
|
call,
|
||||||
@"call fast",
|
@"call fast",
|
||||||
cmpxchg,
|
cmpxchg,
|
||||||
|
|
@ -4345,6 +4347,13 @@ pub const Function = struct {
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn isNosanitize(self: Tag) bool {
|
||||||
|
return switch (self) {
|
||||||
|
.br_cond_nosanitize => true,
|
||||||
|
else => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Index = enum(u32) {
|
pub const Index = enum(u32) {
|
||||||
|
|
@ -4367,6 +4376,7 @@ pub const Function = struct {
|
||||||
return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) {
|
return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) {
|
||||||
.br,
|
.br,
|
||||||
.br_cond,
|
.br_cond,
|
||||||
|
.br_cond_nosanitize,
|
||||||
.ret,
|
.ret,
|
||||||
.@"ret void",
|
.@"ret void",
|
||||||
.@"switch",
|
.@"switch",
|
||||||
|
|
@ -4380,6 +4390,7 @@ pub const Function = struct {
|
||||||
return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) {
|
return switch (wip.instructions.items(.tag)[@intFromEnum(self)]) {
|
||||||
.br,
|
.br,
|
||||||
.br_cond,
|
.br_cond,
|
||||||
|
.br_cond_nosanitize,
|
||||||
.fence,
|
.fence,
|
||||||
.ret,
|
.ret,
|
||||||
.@"ret void",
|
.@"ret void",
|
||||||
|
|
@ -4470,6 +4481,7 @@ pub const Function = struct {
|
||||||
.block => .label,
|
.block => .label,
|
||||||
.br,
|
.br,
|
||||||
.br_cond,
|
.br_cond,
|
||||||
|
.br_cond_nosanitize,
|
||||||
.fence,
|
.fence,
|
||||||
.ret,
|
.ret,
|
||||||
.@"ret void",
|
.@"ret void",
|
||||||
|
|
@ -4656,6 +4668,7 @@ pub const Function = struct {
|
||||||
.block => .label,
|
.block => .label,
|
||||||
.br,
|
.br,
|
||||||
.br_cond,
|
.br_cond,
|
||||||
|
.br_cond_nosanitize,
|
||||||
.fence,
|
.fence,
|
||||||
.ret,
|
.ret,
|
||||||
.@"ret void",
|
.@"ret void",
|
||||||
|
|
@ -5088,6 +5101,7 @@ pub const WipFunction = struct {
|
||||||
instructions: std.MultiArrayList(Instruction),
|
instructions: std.MultiArrayList(Instruction),
|
||||||
names: std.ArrayListUnmanaged(String),
|
names: std.ArrayListUnmanaged(String),
|
||||||
strip: bool,
|
strip: bool,
|
||||||
|
any_nosanitize: bool,
|
||||||
debug_locations: std.AutoArrayHashMapUnmanaged(Instruction.Index, DebugLocation),
|
debug_locations: std.AutoArrayHashMapUnmanaged(Instruction.Index, DebugLocation),
|
||||||
debug_values: std.AutoArrayHashMapUnmanaged(Instruction.Index, void),
|
debug_values: std.AutoArrayHashMapUnmanaged(Instruction.Index, void),
|
||||||
extra: std.ArrayListUnmanaged(u32),
|
extra: std.ArrayListUnmanaged(u32),
|
||||||
|
|
@ -5134,6 +5148,7 @@ pub const WipFunction = struct {
|
||||||
.instructions = .{},
|
.instructions = .{},
|
||||||
.names = .{},
|
.names = .{},
|
||||||
.strip = options.strip,
|
.strip = options.strip,
|
||||||
|
.any_nosanitize = false,
|
||||||
.debug_locations = .{},
|
.debug_locations = .{},
|
||||||
.debug_values = .{},
|
.debug_values = .{},
|
||||||
.extra = .{},
|
.extra = .{},
|
||||||
|
|
@ -5201,11 +5216,34 @@ pub const WipFunction = struct {
|
||||||
cond: Value,
|
cond: Value,
|
||||||
then: Block.Index,
|
then: Block.Index,
|
||||||
@"else": Block.Index,
|
@"else": Block.Index,
|
||||||
|
) Allocator.Error!Instruction.Index {
|
||||||
|
return brCondTag(self, cond, then, @"else", .br_cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn brCondNosanitize(
|
||||||
|
self: *WipFunction,
|
||||||
|
cond: Value,
|
||||||
|
then: Block.Index,
|
||||||
|
@"else": Block.Index,
|
||||||
|
) Allocator.Error!Instruction.Index {
|
||||||
|
self.any_nosanitize = true;
|
||||||
|
return brCondTag(self, cond, then, @"else", .br_cond_nosanitize);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn brCondTag(
|
||||||
|
self: *WipFunction,
|
||||||
|
cond: Value,
|
||||||
|
then: Block.Index,
|
||||||
|
@"else": Block.Index,
|
||||||
|
/// Asserted to be either `.br_cond` or `.br_cond_nosanitize`.
|
||||||
|
tag: Instruction.Tag,
|
||||||
) Allocator.Error!Instruction.Index {
|
) Allocator.Error!Instruction.Index {
|
||||||
assert(cond.typeOfWip(self) == .i1);
|
assert(cond.typeOfWip(self) == .i1);
|
||||||
|
assert(tag == .br_cond or tag == .br_cond_nosanitize);
|
||||||
|
assert(tag != .br_cond_nosanitize or self.any_nosanitize);
|
||||||
try self.ensureUnusedExtraCapacity(1, Instruction.BrCond, 0);
|
try self.ensureUnusedExtraCapacity(1, Instruction.BrCond, 0);
|
||||||
const instruction = try self.addInst(null, .{
|
const instruction = try self.addInst(null, .{
|
||||||
.tag = .br_cond,
|
.tag = tag,
|
||||||
.data = self.addExtraAssumeCapacity(Instruction.BrCond{
|
.data = self.addExtraAssumeCapacity(Instruction.BrCond{
|
||||||
.cond = cond,
|
.cond = cond,
|
||||||
.then = then,
|
.then = then,
|
||||||
|
|
@ -6374,7 +6412,7 @@ pub const WipFunction = struct {
|
||||||
.@"ret void",
|
.@"ret void",
|
||||||
.@"unreachable",
|
.@"unreachable",
|
||||||
=> {},
|
=> {},
|
||||||
.br_cond => {
|
.br_cond, .br_cond_nosanitize => {
|
||||||
const extra = self.extraData(Instruction.BrCond, instruction.data);
|
const extra = self.extraData(Instruction.BrCond, instruction.data);
|
||||||
instruction.data = wip_extra.addExtra(Instruction.BrCond{
|
instruction.data = wip_extra.addExtra(Instruction.BrCond{
|
||||||
.cond = instructions.map(extra.cond),
|
.cond = instructions.map(extra.cond),
|
||||||
|
|
@ -6559,6 +6597,7 @@ pub const WipFunction = struct {
|
||||||
function.names = names.ptr;
|
function.names = names.ptr;
|
||||||
function.value_indices = value_indices.ptr;
|
function.value_indices = value_indices.ptr;
|
||||||
function.strip = self.strip;
|
function.strip = self.strip;
|
||||||
|
function.any_nosanitize = self.any_nosanitize;
|
||||||
function.debug_locations = debug_locations;
|
function.debug_locations = debug_locations;
|
||||||
function.debug_values = debug_values;
|
function.debug_values = debug_values;
|
||||||
}
|
}
|
||||||
|
|
@ -7697,6 +7736,7 @@ pub const MetadataString = enum(u32) {
|
||||||
|
|
||||||
pub const Metadata = enum(u32) {
|
pub const Metadata = enum(u32) {
|
||||||
none = 0,
|
none = 0,
|
||||||
|
empty_tuple = 1,
|
||||||
_,
|
_,
|
||||||
|
|
||||||
const first_forward_reference = 1 << 29;
|
const first_forward_reference = 1 << 29;
|
||||||
|
|
@ -8355,7 +8395,7 @@ pub const Metadata = enum(u32) {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(options: Options) Allocator.Error!Builder {
|
pub fn init(options: Options) Allocator.Error!Builder {
|
||||||
var self = Builder{
|
var self: Builder = .{
|
||||||
.gpa = options.allocator,
|
.gpa = options.allocator,
|
||||||
.strip = options.strip,
|
.strip = options.strip,
|
||||||
|
|
||||||
|
|
@ -8458,6 +8498,7 @@ pub fn init(options: Options) Allocator.Error!Builder {
|
||||||
|
|
||||||
try self.metadata_string_indices.append(self.gpa, 0);
|
try self.metadata_string_indices.append(self.gpa, 0);
|
||||||
assert(try self.metadataString("") == .none);
|
assert(try self.metadataString("") == .none);
|
||||||
|
assert(try self.debugTuple(&.{}) == .empty_tuple);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
@ -8855,6 +8896,7 @@ pub fn addFunctionAssumeCapacity(
|
||||||
.kind = .{ .function = function_index },
|
.kind = .{ .function = function_index },
|
||||||
}),
|
}),
|
||||||
.strip = undefined,
|
.strip = undefined,
|
||||||
|
.any_nosanitize = false,
|
||||||
});
|
});
|
||||||
return function_index;
|
return function_index;
|
||||||
}
|
}
|
||||||
|
|
@ -9502,6 +9544,12 @@ pub fn printUnbuffered(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (function.instructions.len > 0) {
|
if (function.instructions.len > 0) {
|
||||||
|
const maybe_empty_tuple: ?u32 = if (!function.any_nosanitize) null else b: {
|
||||||
|
const gop = try metadata_formatter.map.getOrPut(self.gpa, .{
|
||||||
|
.metadata = .empty_tuple,
|
||||||
|
});
|
||||||
|
break :b @intCast(gop.index);
|
||||||
|
};
|
||||||
var block_incoming_len: u32 = undefined;
|
var block_incoming_len: u32 = undefined;
|
||||||
try writer.writeAll(" {\n");
|
try writer.writeAll(" {\n");
|
||||||
var maybe_dbg_index: ?u32 = null;
|
var maybe_dbg_index: ?u32 = null;
|
||||||
|
|
@ -9684,6 +9732,14 @@ pub fn printUnbuffered(
|
||||||
extra.@"else".toInst(&function).fmt(function_index, self),
|
extra.@"else".toInst(&function).fmt(function_index, self),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
.br_cond_nosanitize => {
|
||||||
|
const extra = function.extraData(Function.Instruction.BrCond, instruction.data);
|
||||||
|
try writer.print(" br {%}, {%}, {%}", .{
|
||||||
|
extra.cond.fmt(function_index, self),
|
||||||
|
extra.then.toInst(&function).fmt(function_index, self),
|
||||||
|
extra.@"else".toInst(&function).fmt(function_index, self),
|
||||||
|
});
|
||||||
|
},
|
||||||
.call,
|
.call,
|
||||||
.@"call fast",
|
.@"call fast",
|
||||||
.@"musttail call",
|
.@"musttail call",
|
||||||
|
|
@ -9950,8 +10006,12 @@ pub fn printUnbuffered(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maybe_dbg_index) |dbg_index| {
|
if (maybe_dbg_index) |dbg_index| {
|
||||||
try writer.print(", !dbg !{}\n", .{dbg_index});
|
try writer.print(", !dbg !{}", .{dbg_index});
|
||||||
} else try writer.writeByte('\n');
|
}
|
||||||
|
if (instruction.tag.isNosanitize()) {
|
||||||
|
try writer.print(", !nosanitize !{d}", .{maybe_empty_tuple.?});
|
||||||
|
}
|
||||||
|
try writer.writeByte('\n');
|
||||||
}
|
}
|
||||||
try writer.writeByte('}');
|
try writer.writeByte('}');
|
||||||
}
|
}
|
||||||
|
|
@ -13759,7 +13819,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
const MetadataKindBlock = ir.MetadataKindBlock;
|
const MetadataKindBlock = ir.MetadataKindBlock;
|
||||||
var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
|
var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
|
||||||
|
|
||||||
inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| {
|
inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| {
|
||||||
try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
|
try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
|
||||||
.id = field.value,
|
.id = field.value,
|
||||||
.name = field.name,
|
.name = field.name,
|
||||||
|
|
@ -14046,7 +14106,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
else
|
else
|
||||||
-%val << 1 | 1);
|
-%val << 1 | 1);
|
||||||
}
|
}
|
||||||
try metadata_block.writeUnabbrev(MetadataBlock.Enumerator.id, record.items);
|
try metadata_block.writeUnabbrev(@intFromEnum(MetadataBlock.Enumerator.id), record.items);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{
|
try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{
|
||||||
|
|
@ -14177,7 +14237,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
|
|
||||||
try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{
|
try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{
|
||||||
.value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())),
|
.value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())),
|
||||||
.kind = ir.MetadataKind.dbg,
|
.kind = .dbg,
|
||||||
.metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1),
|
.metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -14220,20 +14280,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
constant_adapter: ConstantAdapter,
|
constant_adapter: ConstantAdapter,
|
||||||
metadata_adapter: MetadataAdapter,
|
metadata_adapter: MetadataAdapter,
|
||||||
func: *const Function,
|
func: *const Function,
|
||||||
instruction_index: u32 = 0,
|
instruction_index: Function.Instruction.Index,
|
||||||
|
|
||||||
pub fn init(
|
|
||||||
const_adapter: ConstantAdapter,
|
|
||||||
meta_adapter: MetadataAdapter,
|
|
||||||
func: *const Function,
|
|
||||||
) @This() {
|
|
||||||
return .{
|
|
||||||
.constant_adapter = const_adapter,
|
|
||||||
.metadata_adapter = meta_adapter,
|
|
||||||
.func = func,
|
|
||||||
.instruction_index = 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) {
|
pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) {
|
||||||
_ = field_name;
|
_ = field_name;
|
||||||
|
|
@ -14282,19 +14329,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn offset(adapter: @This()) u32 {
|
pub fn offset(adapter: @This()) u32 {
|
||||||
return @as(
|
return adapter.instruction_index.valueIndex(adapter.func) + adapter.firstInstr();
|
||||||
Function.Instruction.Index,
|
|
||||||
@enumFromInt(adapter.instruction_index),
|
|
||||||
).valueIndex(adapter.func) + adapter.firstInstr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn firstInstr(adapter: @This()) u32 {
|
fn firstInstr(adapter: @This()) u32 {
|
||||||
return adapter.constant_adapter.numConstants();
|
return adapter.constant_adapter.numConstants();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next(adapter: *@This()) void {
|
|
||||||
adapter.instruction_index += 1;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (self.functions.items, 0..) |func, func_index| {
|
for (self.functions.items, 0..) |func, func_index| {
|
||||||
|
|
@ -14307,7 +14347,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
|
|
||||||
try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len });
|
try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len });
|
||||||
|
|
||||||
var adapter = FunctionAdapter.init(constant_adapter, metadata_adapter, &func);
|
var adapter: FunctionAdapter = .{
|
||||||
|
.constant_adapter = constant_adapter,
|
||||||
|
.metadata_adapter = metadata_adapter,
|
||||||
|
.func = &func,
|
||||||
|
.instruction_index = @enumFromInt(0),
|
||||||
|
};
|
||||||
|
|
||||||
// Emit function level metadata block
|
// Emit function level metadata block
|
||||||
if (!func.strip and func.debug_values.len > 0) {
|
if (!func.strip and func.debug_values.len > 0) {
|
||||||
|
|
@ -14330,21 +14375,23 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
var has_location = false;
|
var has_location = false;
|
||||||
|
|
||||||
var block_incoming_len: u32 = undefined;
|
var block_incoming_len: u32 = undefined;
|
||||||
for (0..func.instructions.len) |instr_index| {
|
for (tags, datas, 0..) |tag, data, instr_index| {
|
||||||
const tag = tags[instr_index];
|
adapter.instruction_index = @enumFromInt(instr_index);
|
||||||
|
|
||||||
record.clearRetainingCapacity();
|
record.clearRetainingCapacity();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
.block => block_incoming_len = datas[instr_index],
|
.arg => continue,
|
||||||
.arg => {},
|
.block => {
|
||||||
|
block_incoming_len = data;
|
||||||
|
continue;
|
||||||
|
},
|
||||||
.@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}),
|
.@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}),
|
||||||
.call,
|
.call,
|
||||||
.@"musttail call",
|
.@"musttail call",
|
||||||
.@"notail call",
|
.@"notail call",
|
||||||
.@"tail call",
|
.@"tail call",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.Call, data);
|
||||||
|
|
||||||
const call_conv = extra.data.info.call_conv;
|
const call_conv = extra.data.info.call_conv;
|
||||||
const args = extra.trail.next(extra.data.args_len, Value, &func);
|
const args = extra.trail.next(extra.data.args_len, Value, &func);
|
||||||
|
|
@ -14367,7 +14414,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"notail call fast",
|
.@"notail call fast",
|
||||||
.@"tail call fast",
|
.@"tail call fast",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.Call, data);
|
||||||
|
|
||||||
const call_conv = extra.data.info.call_conv;
|
const call_conv = extra.data.info.call_conv;
|
||||||
const args = extra.trail.next(extra.data.args_len, Value, &func);
|
const args = extra.trail.next(extra.data.args_len, Value, &func);
|
||||||
|
|
@ -14405,7 +14452,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.srem,
|
.srem,
|
||||||
.ashr,
|
.ashr,
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Binary{
|
try function_block.writeAbbrev(FunctionBlock.Binary{
|
||||||
.opcode = kind.toBinaryOpcode(),
|
.opcode = kind.toBinaryOpcode(),
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
|
|
@ -14417,7 +14464,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"lshr exact",
|
.@"lshr exact",
|
||||||
.@"ashr exact",
|
.@"ashr exact",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.BinaryExact{
|
try function_block.writeAbbrev(FunctionBlock.BinaryExact{
|
||||||
.opcode = kind.toBinaryOpcode(),
|
.opcode = kind.toBinaryOpcode(),
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
|
|
@ -14437,7 +14484,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"shl nuw",
|
.@"shl nuw",
|
||||||
.@"shl nuw nsw",
|
.@"shl nuw nsw",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{
|
try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{
|
||||||
.opcode = kind.toBinaryOpcode(),
|
.opcode = kind.toBinaryOpcode(),
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
|
|
@ -14468,7 +14515,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"frem fast",
|
.@"frem fast",
|
||||||
.@"fsub fast",
|
.@"fsub fast",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.BinaryFast{
|
try function_block.writeAbbrev(FunctionBlock.BinaryFast{
|
||||||
.opcode = kind.toBinaryOpcode(),
|
.opcode = kind.toBinaryOpcode(),
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
|
|
@ -14479,7 +14526,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.alloca,
|
.alloca,
|
||||||
.@"alloca inalloca",
|
.@"alloca inalloca",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Alloca, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Alloca, data);
|
||||||
const alignment = extra.info.alignment.toLlvm();
|
const alignment = extra.info.alignment.toLlvm();
|
||||||
try function_block.writeAbbrev(FunctionBlock.Alloca{
|
try function_block.writeAbbrev(FunctionBlock.Alloca{
|
||||||
.inst_type = extra.type,
|
.inst_type = extra.type,
|
||||||
|
|
@ -14508,7 +14555,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.sext,
|
.sext,
|
||||||
.zext,
|
.zext,
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Cast, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Cast, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Cast{
|
try function_block.writeAbbrev(FunctionBlock.Cast{
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
.type_index = extra.type,
|
.type_index = extra.type,
|
||||||
|
|
@ -14542,7 +14589,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"icmp ule",
|
.@"icmp ule",
|
||||||
.@"icmp ult",
|
.@"icmp ult",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Cmp{
|
try function_block.writeAbbrev(FunctionBlock.Cmp{
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
||||||
|
|
@ -14566,7 +14613,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.@"fcmp fast une",
|
.@"fcmp fast une",
|
||||||
.@"fcmp fast uno",
|
.@"fcmp fast uno",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Binary, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.CmpFast{
|
try function_block.writeAbbrev(FunctionBlock.CmpFast{
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
||||||
|
|
@ -14575,14 +14622,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{
|
.fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{
|
||||||
.val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
|
.val = adapter.getOffsetValueIndex(@enumFromInt(data)),
|
||||||
}),
|
}),
|
||||||
.@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{
|
.@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{
|
||||||
.val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
|
.val = adapter.getOffsetValueIndex(@enumFromInt(data)),
|
||||||
.fast_math = FastMath.fast,
|
.fast_math = FastMath.fast,
|
||||||
}),
|
}),
|
||||||
.extractvalue => {
|
.extractvalue => {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.ExtractValue, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.ExtractValue, data);
|
||||||
const indices = extra.trail.next(extra.data.indices_len, u32, &func);
|
const indices = extra.trail.next(extra.data.indices_len, u32, &func);
|
||||||
try function_block.writeAbbrev(FunctionBlock.ExtractValue{
|
try function_block.writeAbbrev(FunctionBlock.ExtractValue{
|
||||||
.val = adapter.getOffsetValueIndex(extra.data.val),
|
.val = adapter.getOffsetValueIndex(extra.data.val),
|
||||||
|
|
@ -14590,7 +14637,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.insertvalue => {
|
.insertvalue => {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.InsertValue, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.InsertValue, data);
|
||||||
const indices = extra.trail.next(extra.data.indices_len, u32, &func);
|
const indices = extra.trail.next(extra.data.indices_len, u32, &func);
|
||||||
try function_block.writeAbbrev(FunctionBlock.InsertValue{
|
try function_block.writeAbbrev(FunctionBlock.InsertValue{
|
||||||
.val = adapter.getOffsetValueIndex(extra.data.val),
|
.val = adapter.getOffsetValueIndex(extra.data.val),
|
||||||
|
|
@ -14599,14 +14646,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.extractelement => {
|
.extractelement => {
|
||||||
const extra = func.extraData(Function.Instruction.ExtractElement, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.ExtractElement, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.ExtractElement{
|
try function_block.writeAbbrev(FunctionBlock.ExtractElement{
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
.index = adapter.getOffsetValueIndex(extra.index),
|
.index = adapter.getOffsetValueIndex(extra.index),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.insertelement => {
|
.insertelement => {
|
||||||
const extra = func.extraData(Function.Instruction.InsertElement, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.InsertElement, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.InsertElement{
|
try function_block.writeAbbrev(FunctionBlock.InsertElement{
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
.elem = adapter.getOffsetValueIndex(extra.elem),
|
.elem = adapter.getOffsetValueIndex(extra.elem),
|
||||||
|
|
@ -14614,7 +14661,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.select => {
|
.select => {
|
||||||
const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Select, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Select{
|
try function_block.writeAbbrev(FunctionBlock.Select{
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
||||||
|
|
@ -14622,7 +14669,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"select fast" => {
|
.@"select fast" => {
|
||||||
const extra = func.extraData(Function.Instruction.Select, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Select, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.SelectFast{
|
try function_block.writeAbbrev(FunctionBlock.SelectFast{
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
||||||
|
|
@ -14631,7 +14678,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.shufflevector => {
|
.shufflevector => {
|
||||||
const extra = func.extraData(Function.Instruction.ShuffleVector, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.ShuffleVector, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.ShuffleVector{
|
try function_block.writeAbbrev(FunctionBlock.ShuffleVector{
|
||||||
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
.lhs = adapter.getOffsetValueIndex(extra.lhs),
|
||||||
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
.rhs = adapter.getOffsetValueIndex(extra.rhs),
|
||||||
|
|
@ -14641,7 +14688,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.getelementptr,
|
.getelementptr,
|
||||||
.@"getelementptr inbounds",
|
.@"getelementptr inbounds",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, data);
|
||||||
const indices = extra.trail.next(extra.data.indices_len, Value, &func);
|
const indices = extra.trail.next(extra.data.indices_len, Value, &func);
|
||||||
try function_block.writeAbbrevAdapted(
|
try function_block.writeAbbrevAdapted(
|
||||||
FunctionBlock.GetElementPtr{
|
FunctionBlock.GetElementPtr{
|
||||||
|
|
@ -14654,7 +14701,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
.load => {
|
.load => {
|
||||||
const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Load, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Load{
|
try function_block.writeAbbrev(FunctionBlock.Load{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
.ty = extra.type,
|
.ty = extra.type,
|
||||||
|
|
@ -14663,7 +14710,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"load atomic" => {
|
.@"load atomic" => {
|
||||||
const extra = func.extraData(Function.Instruction.Load, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Load, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.LoadAtomic{
|
try function_block.writeAbbrev(FunctionBlock.LoadAtomic{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
.ty = extra.type,
|
.ty = extra.type,
|
||||||
|
|
@ -14674,7 +14721,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.store => {
|
.store => {
|
||||||
const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Store, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Store{
|
try function_block.writeAbbrev(FunctionBlock.Store{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
|
|
@ -14683,7 +14730,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"store atomic" => {
|
.@"store atomic" => {
|
||||||
const extra = func.extraData(Function.Instruction.Store, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.Store, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.StoreAtomic{
|
try function_block.writeAbbrev(FunctionBlock.StoreAtomic{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
|
|
@ -14695,11 +14742,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
},
|
},
|
||||||
.br => {
|
.br => {
|
||||||
try function_block.writeAbbrev(FunctionBlock.BrUnconditional{
|
try function_block.writeAbbrev(FunctionBlock.BrUnconditional{
|
||||||
.block = datas[instr_index],
|
.block = data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.br_cond => {
|
.br_cond, .br_cond_nosanitize => {
|
||||||
const extra = func.extraData(Function.Instruction.BrCond, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.BrCond, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.BrConditional{
|
try function_block.writeAbbrev(FunctionBlock.BrConditional{
|
||||||
.then_block = @intFromEnum(extra.then),
|
.then_block = @intFromEnum(extra.then),
|
||||||
.else_block = @intFromEnum(extra.@"else"),
|
.else_block = @intFromEnum(extra.@"else"),
|
||||||
|
|
@ -14707,7 +14754,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.@"switch" => {
|
.@"switch" => {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.Switch, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.Switch, data);
|
||||||
|
|
||||||
try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2);
|
try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2);
|
||||||
|
|
||||||
|
|
@ -14730,7 +14777,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
try function_block.writeUnabbrev(12, record.items);
|
try function_block.writeUnabbrev(12, record.items);
|
||||||
},
|
},
|
||||||
.va_arg => {
|
.va_arg => {
|
||||||
const extra = func.extraData(Function.Instruction.VaArg, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.VaArg, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.VaArg{
|
try function_block.writeAbbrev(FunctionBlock.VaArg{
|
||||||
.list_type = extra.list.typeOf(@enumFromInt(func_index), self),
|
.list_type = extra.list.typeOf(@enumFromInt(func_index), self),
|
||||||
.list = adapter.getOffsetValueIndex(extra.list),
|
.list = adapter.getOffsetValueIndex(extra.list),
|
||||||
|
|
@ -14740,7 +14787,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.phi,
|
.phi,
|
||||||
.@"phi fast",
|
.@"phi fast",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
var extra = func.extraDataTrail(Function.Instruction.Phi, datas[instr_index]);
|
var extra = func.extraDataTrail(Function.Instruction.Phi, data);
|
||||||
const vals = extra.trail.next(block_incoming_len, Value, &func);
|
const vals = extra.trail.next(block_incoming_len, Value, &func);
|
||||||
const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func);
|
const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func);
|
||||||
|
|
||||||
|
|
@ -14764,11 +14811,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
try function_block.writeUnabbrev(16, record.items);
|
try function_block.writeUnabbrev(16, record.items);
|
||||||
},
|
},
|
||||||
.ret => try function_block.writeAbbrev(FunctionBlock.Ret{
|
.ret => try function_block.writeAbbrev(FunctionBlock.Ret{
|
||||||
.val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])),
|
.val = adapter.getOffsetValueIndex(@enumFromInt(data)),
|
||||||
}),
|
}),
|
||||||
.@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}),
|
.@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}),
|
||||||
.atomicrmw => {
|
.atomicrmw => {
|
||||||
const extra = func.extraData(Function.Instruction.AtomicRmw, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.AtomicRmw, data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.AtomicRmw{
|
try function_block.writeAbbrev(FunctionBlock.AtomicRmw{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
.val = adapter.getOffsetValueIndex(extra.val),
|
.val = adapter.getOffsetValueIndex(extra.val),
|
||||||
|
|
@ -14782,7 +14829,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
.cmpxchg,
|
.cmpxchg,
|
||||||
.@"cmpxchg weak",
|
.@"cmpxchg weak",
|
||||||
=> |kind| {
|
=> |kind| {
|
||||||
const extra = func.extraData(Function.Instruction.CmpXchg, datas[instr_index]);
|
const extra = func.extraData(Function.Instruction.CmpXchg, data);
|
||||||
|
|
||||||
try function_block.writeAbbrev(FunctionBlock.CmpXchg{
|
try function_block.writeAbbrev(FunctionBlock.CmpXchg{
|
||||||
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
.ptr = adapter.getOffsetValueIndex(extra.ptr),
|
||||||
|
|
@ -14797,7 +14844,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
.fence => {
|
.fence => {
|
||||||
const info: MemoryAccessInfo = @bitCast(datas[instr_index]);
|
const info: MemoryAccessInfo = @bitCast(data);
|
||||||
try function_block.writeAbbrev(FunctionBlock.Fence{
|
try function_block.writeAbbrev(FunctionBlock.Fence{
|
||||||
.ordering = info.success_ordering,
|
.ordering = info.success_ordering,
|
||||||
.sync_scope = info.sync_scope,
|
.sync_scope = info.sync_scope,
|
||||||
|
|
@ -14806,7 +14853,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!func.strip) {
|
if (!func.strip) {
|
||||||
if (func.debug_locations.get(@enumFromInt(instr_index))) |debug_location| {
|
if (func.debug_locations.get(adapter.instruction_index)) |debug_location| {
|
||||||
switch (debug_location) {
|
switch (debug_location) {
|
||||||
.no_location => has_location = false,
|
.no_location => has_location = false,
|
||||||
.location => |location| {
|
.location => |location| {
|
||||||
|
|
@ -14823,8 +14870,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{});
|
try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VALUE_SYMTAB
|
// VALUE_SYMTAB
|
||||||
|
|
@ -14850,18 +14895,34 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
|
||||||
}
|
}
|
||||||
|
|
||||||
// METADATA_ATTACHMENT_BLOCK
|
// METADATA_ATTACHMENT_BLOCK
|
||||||
if (!func.strip) blk: {
|
if (!func.strip or func.any_nosanitize) {
|
||||||
const dbg = func.global.ptrConst(self).dbg;
|
|
||||||
|
|
||||||
if (dbg == .none) break :blk;
|
|
||||||
|
|
||||||
const MetadataAttachmentBlock = ir.MetadataAttachmentBlock;
|
const MetadataAttachmentBlock = ir.MetadataAttachmentBlock;
|
||||||
var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false);
|
var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false);
|
||||||
|
|
||||||
try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{
|
if (!func.strip) blk: {
|
||||||
.kind = ir.MetadataKind.dbg,
|
const dbg = func.global.ptrConst(self).dbg;
|
||||||
.metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),
|
if (dbg == .none) break :blk;
|
||||||
});
|
try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentGlobalSingle{
|
||||||
|
.kind = .dbg,
|
||||||
|
.metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var instr_index: u32 = 0;
|
||||||
|
for (func.instructions.items(.tag)) |instr_tag| switch (instr_tag) {
|
||||||
|
.arg, .block => {},
|
||||||
|
.br_cond_nosanitize => {
|
||||||
|
try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{
|
||||||
|
.inst = instr_index,
|
||||||
|
.kind = .nosanitize,
|
||||||
|
.metadata = @enumFromInt(metadata_adapter.getMetadataIndex(.empty_tuple) - 1),
|
||||||
|
});
|
||||||
|
instr_index += 1;
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
instr_index += 1;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
try metadata_attach_block.end();
|
try metadata_attach_block.end();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,142 @@ const ColumnAbbrev = AbbrevOp{ .vbr = 8 };
|
||||||
|
|
||||||
const BlockAbbrev = AbbrevOp{ .vbr = 6 };
|
const BlockAbbrev = AbbrevOp{ .vbr = 6 };
|
||||||
|
|
||||||
pub const MetadataKind = enum(u1) {
|
/// Unused tags are commented out so that they are omitted in the generated
|
||||||
|
/// bitcode, which scans over this enum using reflection.
|
||||||
|
pub const FixedMetadataKind = enum(u8) {
|
||||||
dbg = 0,
|
dbg = 0,
|
||||||
|
//tbaa = 1,
|
||||||
|
//prof = 2,
|
||||||
|
//fpmath = 3,
|
||||||
|
//range = 4,
|
||||||
|
//@"tbaa.struct" = 5,
|
||||||
|
//@"invariant.load" = 6,
|
||||||
|
//@"alias.scope" = 7,
|
||||||
|
//@"noalias" = 8,
|
||||||
|
//nontemporal = 9,
|
||||||
|
//@"llvm.mem.parallel_loop_access" = 10,
|
||||||
|
//nonnull = 11,
|
||||||
|
//dereferenceable = 12,
|
||||||
|
//dereferenceable_or_null = 13,
|
||||||
|
//@"make.implicit" = 14,
|
||||||
|
//unpredictable = 15,
|
||||||
|
//@"invariant.group" = 16,
|
||||||
|
//@"align" = 17,
|
||||||
|
//@"llvm.loop" = 18,
|
||||||
|
//type = 19,
|
||||||
|
//section_prefix = 20,
|
||||||
|
//absolute_symbol = 21,
|
||||||
|
//associated = 22,
|
||||||
|
//callees = 23,
|
||||||
|
//irr_loop = 24,
|
||||||
|
//@"llvm.access.group" = 25,
|
||||||
|
//callback = 26,
|
||||||
|
//@"llvm.preserve.access.index" = 27,
|
||||||
|
//vcall_visibility = 28,
|
||||||
|
//noundef = 29,
|
||||||
|
//annotation = 30,
|
||||||
|
nosanitize = 31,
|
||||||
|
//func_sanitize = 32,
|
||||||
|
//exclude = 33,
|
||||||
|
//memprof = 34,
|
||||||
|
//callsite = 35,
|
||||||
|
//kcfi_type = 36,
|
||||||
|
//pcsections = 37,
|
||||||
|
//DIAssignID = 38,
|
||||||
|
//@"coro.outside.frame" = 39,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const MetadataCode = enum(u8) {
|
||||||
|
/// MDSTRING: [values]
|
||||||
|
STRING_OLD = 1,
|
||||||
|
/// VALUE: [type num, value num]
|
||||||
|
VALUE = 2,
|
||||||
|
/// NODE: [n x md num]
|
||||||
|
NODE = 3,
|
||||||
|
/// STRING: [values]
|
||||||
|
NAME = 4,
|
||||||
|
/// DISTINCT_NODE: [n x md num]
|
||||||
|
DISTINCT_NODE = 5,
|
||||||
|
/// [n x [id, name]]
|
||||||
|
KIND = 6,
|
||||||
|
/// [distinct, line, col, scope, inlined-at?]
|
||||||
|
LOCATION = 7,
|
||||||
|
/// OLD_NODE: [n x (type num, value num)]
|
||||||
|
OLD_NODE = 8,
|
||||||
|
/// OLD_FN_NODE: [n x (type num, value num)]
|
||||||
|
OLD_FN_NODE = 9,
|
||||||
|
/// NAMED_NODE: [n x mdnodes]
|
||||||
|
NAMED_NODE = 10,
|
||||||
|
/// [m x [value, [n x [id, mdnode]]]
|
||||||
|
ATTACHMENT = 11,
|
||||||
|
/// [distinct, tag, vers, header, n x md num]
|
||||||
|
GENERIC_DEBUG = 12,
|
||||||
|
/// [distinct, count, lo]
|
||||||
|
SUBRANGE = 13,
|
||||||
|
/// [isUnsigned|distinct, value, name]
|
||||||
|
ENUMERATOR = 14,
|
||||||
|
/// [distinct, tag, name, size, align, enc]
|
||||||
|
BASIC_TYPE = 15,
|
||||||
|
/// [distinct, filename, directory, checksumkind, checksum]
|
||||||
|
FILE = 16,
|
||||||
|
/// [distinct, ...]
|
||||||
|
DERIVED_TYPE = 17,
|
||||||
|
/// [distinct, ...]
|
||||||
|
COMPOSITE_TYPE = 18,
|
||||||
|
/// [distinct, flags, types, cc]
|
||||||
|
SUBROUTINE_TYPE = 19,
|
||||||
|
/// [distinct, ...]
|
||||||
|
COMPILE_UNIT = 20,
|
||||||
|
/// [distinct, ...]
|
||||||
|
SUBPROGRAM = 21,
|
||||||
|
/// [distinct, scope, file, line, column]
|
||||||
|
LEXICAL_BLOCK = 22,
|
||||||
|
///[distinct, scope, file, discriminator]
|
||||||
|
LEXICAL_BLOCK_FILE = 23,
|
||||||
|
/// [distinct, scope, file, name, line, exportSymbols]
|
||||||
|
NAMESPACE = 24,
|
||||||
|
/// [distinct, scope, name, type, ...]
|
||||||
|
TEMPLATE_TYPE = 25,
|
||||||
|
/// [distinct, scope, name, type, value, ...]
|
||||||
|
TEMPLATE_VALUE = 26,
|
||||||
|
/// [distinct, ...]
|
||||||
|
GLOBAL_VAR = 27,
|
||||||
|
/// [distinct, ...]
|
||||||
|
LOCAL_VAR = 28,
|
||||||
|
/// [distinct, n x element]
|
||||||
|
EXPRESSION = 29,
|
||||||
|
/// [distinct, name, file, line, ...]
|
||||||
|
OBJC_PROPERTY = 30,
|
||||||
|
/// [distinct, tag, scope, entity, line, name]
|
||||||
|
IMPORTED_ENTITY = 31,
|
||||||
|
/// [distinct, scope, name, ...]
|
||||||
|
MODULE = 32,
|
||||||
|
/// [distinct, macinfo, line, name, value]
|
||||||
|
MACRO = 33,
|
||||||
|
/// [distinct, macinfo, line, file, ...]
|
||||||
|
MACRO_FILE = 34,
|
||||||
|
/// [count, offset] blob([lengths][chars])
|
||||||
|
STRINGS = 35,
|
||||||
|
/// [valueid, n x [id, mdnode]]
|
||||||
|
GLOBAL_DECL_ATTACHMENT = 36,
|
||||||
|
/// [distinct, var, expr]
|
||||||
|
GLOBAL_VAR_EXPR = 37,
|
||||||
|
/// [offset]
|
||||||
|
INDEX_OFFSET = 38,
|
||||||
|
/// [bitpos]
|
||||||
|
INDEX = 39,
|
||||||
|
/// [distinct, scope, name, file, line]
|
||||||
|
LABEL = 40,
|
||||||
|
/// [distinct, name, size, align,...]
|
||||||
|
STRING_TYPE = 41,
|
||||||
|
/// [distinct, scope, name, variable,...]
|
||||||
|
COMMON_BLOCK = 44,
|
||||||
|
/// [distinct, count, lo, up, stride]
|
||||||
|
GENERIC_SUBRANGE = 45,
|
||||||
|
/// [n x [type num, value num]]
|
||||||
|
ARG_LIST = 46,
|
||||||
|
/// [distinct, ...]
|
||||||
|
ASSIGN_ID = 47,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Identification = struct {
|
pub const Identification = struct {
|
||||||
|
|
@ -622,16 +756,29 @@ pub const MetadataAttachmentBlock = struct {
|
||||||
pub const id = 16;
|
pub const id = 16;
|
||||||
|
|
||||||
pub const abbrevs = [_]type{
|
pub const abbrevs = [_]type{
|
||||||
AttachmentSingle,
|
AttachmentGlobalSingle,
|
||||||
|
AttachmentInstructionSingle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const AttachmentSingle = struct {
|
pub const AttachmentGlobalSingle = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 11 },
|
.{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
|
||||||
.{ .fixed = 1 },
|
.{ .fixed = 1 },
|
||||||
MetadataAbbrev,
|
MetadataAbbrev,
|
||||||
};
|
};
|
||||||
kind: MetadataKind,
|
kind: FixedMetadataKind,
|
||||||
|
metadata: Builder.Metadata,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const AttachmentInstructionSingle = struct {
|
||||||
|
pub const ops = [_]AbbrevOp{
|
||||||
|
.{ .literal = @intFromEnum(MetadataCode.ATTACHMENT) },
|
||||||
|
ValueAbbrev,
|
||||||
|
.{ .fixed = 5 },
|
||||||
|
MetadataAbbrev,
|
||||||
|
};
|
||||||
|
inst: u32,
|
||||||
|
kind: FixedMetadataKind,
|
||||||
metadata: Builder.Metadata,
|
metadata: Builder.Metadata,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -666,7 +813,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Strings = struct {
|
pub const Strings = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 35 },
|
.{ .literal = @intFromEnum(MetadataCode.STRINGS) },
|
||||||
.{ .vbr = 6 },
|
.{ .vbr = 6 },
|
||||||
.{ .vbr = 6 },
|
.{ .vbr = 6 },
|
||||||
.blob,
|
.blob,
|
||||||
|
|
@ -678,7 +825,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const File = struct {
|
pub const File = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 16 },
|
.{ .literal = @intFromEnum(MetadataCode.FILE) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
MetadataAbbrev, // filename
|
MetadataAbbrev, // filename
|
||||||
MetadataAbbrev, // directory
|
MetadataAbbrev, // directory
|
||||||
|
|
@ -692,7 +839,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const CompileUnit = struct {
|
pub const CompileUnit = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 20 },
|
.{ .literal = @intFromEnum(MetadataCode.COMPILE_UNIT) },
|
||||||
.{ .literal = 1 }, // is distinct
|
.{ .literal = 1 }, // is distinct
|
||||||
.{ .literal = std.dwarf.LANG.C99 }, // source language
|
.{ .literal = std.dwarf.LANG.C99 }, // source language
|
||||||
MetadataAbbrev, // file
|
MetadataAbbrev, // file
|
||||||
|
|
@ -726,7 +873,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Subprogram = struct {
|
pub const Subprogram = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 21 },
|
.{ .literal = @intFromEnum(MetadataCode.SUBPROGRAM) },
|
||||||
.{ .literal = 0b111 }, // is distinct | has sp flags | has flags
|
.{ .literal = 0b111 }, // is distinct | has sp flags | has flags
|
||||||
MetadataAbbrev, // scope
|
MetadataAbbrev, // scope
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -763,7 +910,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const LexicalBlock = struct {
|
pub const LexicalBlock = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 22 },
|
.{ .literal = @intFromEnum(MetadataCode.LEXICAL_BLOCK) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
MetadataAbbrev, // scope
|
MetadataAbbrev, // scope
|
||||||
MetadataAbbrev, // file
|
MetadataAbbrev, // file
|
||||||
|
|
@ -779,7 +926,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Location = struct {
|
pub const Location = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 7 },
|
.{ .literal = @intFromEnum(MetadataCode.LOCATION) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
LineAbbrev, // line
|
LineAbbrev, // line
|
||||||
ColumnAbbrev, // column
|
ColumnAbbrev, // column
|
||||||
|
|
@ -796,7 +943,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const BasicType = struct {
|
pub const BasicType = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 15 },
|
.{ .literal = @intFromEnum(MetadataCode.BASIC_TYPE) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
.{ .literal = std.dwarf.TAG.base_type }, // tag
|
.{ .literal = std.dwarf.TAG.base_type }, // tag
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -813,7 +960,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const CompositeType = struct {
|
pub const CompositeType = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 18 },
|
.{ .literal = @intFromEnum(MetadataCode.COMPOSITE_TYPE) },
|
||||||
.{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref
|
.{ .literal = 0 | 0x2 }, // is distinct | is not used in old type ref
|
||||||
.{ .fixed = 32 }, // tag
|
.{ .fixed = 32 }, // tag
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -852,7 +999,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const DerivedType = struct {
|
pub const DerivedType = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 17 },
|
.{ .literal = @intFromEnum(MetadataCode.DERIVED_TYPE) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
.{ .fixed = 32 }, // tag
|
.{ .fixed = 32 }, // tag
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -880,7 +1027,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const SubroutineType = struct {
|
pub const SubroutineType = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 19 },
|
.{ .literal = @intFromEnum(MetadataCode.SUBROUTINE_TYPE) },
|
||||||
.{ .literal = 0 | 0x2 }, // is distinct | has no old type refs
|
.{ .literal = 0 | 0x2 }, // is distinct | has no old type refs
|
||||||
.{ .literal = 0 }, // flags
|
.{ .literal = 0 }, // flags
|
||||||
MetadataAbbrev, // types
|
MetadataAbbrev, // types
|
||||||
|
|
@ -891,7 +1038,7 @@ pub const MetadataBlock = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Enumerator = struct {
|
pub const Enumerator = struct {
|
||||||
pub const id = 14;
|
pub const id: MetadataCode = .ENUMERATOR;
|
||||||
|
|
||||||
pub const Flags = packed struct(u3) {
|
pub const Flags = packed struct(u3) {
|
||||||
distinct: bool = false,
|
distinct: bool = false,
|
||||||
|
|
@ -900,7 +1047,7 @@ pub const MetadataBlock = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = Enumerator.id },
|
.{ .literal = @intFromEnum(Enumerator.id) },
|
||||||
.{ .fixed = @bitSizeOf(Flags) }, // flags
|
.{ .fixed = @bitSizeOf(Flags) }, // flags
|
||||||
.{ .vbr = 6 }, // bit width
|
.{ .vbr = 6 }, // bit width
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -915,7 +1062,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Subrange = struct {
|
pub const Subrange = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 13 },
|
.{ .literal = @intFromEnum(MetadataCode.SUBRANGE) },
|
||||||
.{ .literal = 0b10 }, // is distinct | version
|
.{ .literal = 0b10 }, // is distinct | version
|
||||||
MetadataAbbrev, // count
|
MetadataAbbrev, // count
|
||||||
MetadataAbbrev, // lower bound
|
MetadataAbbrev, // lower bound
|
||||||
|
|
@ -929,7 +1076,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Expression = struct {
|
pub const Expression = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 29 },
|
.{ .literal = @intFromEnum(MetadataCode.EXPRESSION) },
|
||||||
.{ .literal = 0 | (3 << 1) }, // is distinct | version
|
.{ .literal = 0 | (3 << 1) }, // is distinct | version
|
||||||
MetadataArrayAbbrev, // elements
|
MetadataArrayAbbrev, // elements
|
||||||
};
|
};
|
||||||
|
|
@ -939,7 +1086,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Node = struct {
|
pub const Node = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 3 },
|
.{ .literal = @intFromEnum(MetadataCode.NODE) },
|
||||||
MetadataArrayAbbrev, // elements
|
MetadataArrayAbbrev, // elements
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -948,7 +1095,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const LocalVar = struct {
|
pub const LocalVar = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 28 },
|
.{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
|
||||||
.{ .literal = 0b10 }, // is distinct | has alignment
|
.{ .literal = 0b10 }, // is distinct | has alignment
|
||||||
MetadataAbbrev, // scope
|
MetadataAbbrev, // scope
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -970,7 +1117,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Parameter = struct {
|
pub const Parameter = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 28 },
|
.{ .literal = @intFromEnum(MetadataCode.LOCAL_VAR) },
|
||||||
.{ .literal = 0b10 }, // is distinct | has alignment
|
.{ .literal = 0b10 }, // is distinct | has alignment
|
||||||
MetadataAbbrev, // scope
|
MetadataAbbrev, // scope
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -993,7 +1140,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const GlobalVar = struct {
|
pub const GlobalVar = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 27 },
|
.{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR) },
|
||||||
.{ .literal = 0b101 }, // is distinct | version
|
.{ .literal = 0b101 }, // is distinct | version
|
||||||
MetadataAbbrev, // scope
|
MetadataAbbrev, // scope
|
||||||
MetadataAbbrev, // name
|
MetadataAbbrev, // name
|
||||||
|
|
@ -1020,7 +1167,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const GlobalVarExpression = struct {
|
pub const GlobalVarExpression = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 37 },
|
.{ .literal = @intFromEnum(MetadataCode.GLOBAL_VAR_EXPR) },
|
||||||
.{ .literal = 0 }, // is distinct
|
.{ .literal = 0 }, // is distinct
|
||||||
MetadataAbbrev, // variable
|
MetadataAbbrev, // variable
|
||||||
MetadataAbbrev, // expression
|
MetadataAbbrev, // expression
|
||||||
|
|
@ -1032,7 +1179,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Constant = struct {
|
pub const Constant = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 2 },
|
.{ .literal = @intFromEnum(MetadataCode.VALUE) },
|
||||||
MetadataAbbrev, // type
|
MetadataAbbrev, // type
|
||||||
MetadataAbbrev, // value
|
MetadataAbbrev, // value
|
||||||
};
|
};
|
||||||
|
|
@ -1043,7 +1190,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const Name = struct {
|
pub const Name = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 4 },
|
.{ .literal = @intFromEnum(MetadataCode.NAME) },
|
||||||
.{ .array_fixed = 8 }, // name
|
.{ .array_fixed = 8 }, // name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1052,7 +1199,7 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const NamedNode = struct {
|
pub const NamedNode = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 10 },
|
.{ .literal = @intFromEnum(MetadataCode.NAMED_NODE) },
|
||||||
MetadataArrayAbbrev, // elements
|
MetadataArrayAbbrev, // elements
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1061,14 +1208,14 @@ pub const MetadataBlock = struct {
|
||||||
|
|
||||||
pub const GlobalDeclAttachment = struct {
|
pub const GlobalDeclAttachment = struct {
|
||||||
pub const ops = [_]AbbrevOp{
|
pub const ops = [_]AbbrevOp{
|
||||||
.{ .literal = 36 },
|
.{ .literal = @intFromEnum(MetadataCode.GLOBAL_DECL_ATTACHMENT) },
|
||||||
ValueAbbrev, // value id
|
ValueAbbrev, // value id
|
||||||
.{ .fixed = 1 }, // kind
|
.{ .fixed = 1 }, // kind
|
||||||
MetadataAbbrev, // elements
|
MetadataAbbrev, // elements
|
||||||
};
|
};
|
||||||
|
|
||||||
value: Builder.Constant,
|
value: Builder.Constant,
|
||||||
kind: MetadataKind,
|
kind: FixedMetadataKind,
|
||||||
metadata: Builder.Metadata,
|
metadata: Builder.Metadata,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue