Skip to content

Commit

Permalink
Address Spaces: Restructure llvmAddressSpace a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Snektron committed Sep 4, 2021
1 parent ce2c618 commit a56ea37
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 51 deletions.
19 changes: 8 additions & 11 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,15 @@ pub const DeclGen = struct {

fn llvmAddressSpace(self: DeclGen, address_space: std.builtin.AddressSpace) c_uint {
const target = self.module.getTarget();
return switch (address_space) {
.generic => llvm.address_space.default,
.gs => switch (target.cpu.arch) {
.i386, .x86_64 => llvm.address_space.x86.gs,
else => unreachable,
},
.fs => switch (target.cpu.arch) {
.i386, .x86_64 => llvm.address_space.x86.fs,
else => unreachable,
return switch (target.cpu.arch) {
.i386, .x86_64 => switch (address_space) {
.generic => llvm.address_space.default,
.gs => llvm.address_space.x86.gs,
.fs => llvm.address_space.x86.fs,
.ss => llvm.address_space.x86.ss,
},
.ss => switch (target.cpu.arch) {
.i386, .x86_64 => llvm.address_space.x86.ss,
else => switch (address_space) {
.generic => llvm.address_space.default,
else => unreachable,
},
};
Expand Down
81 changes: 41 additions & 40 deletions src/codegen/llvm/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -853,62 +853,63 @@ pub const Linkage = enum(c_uint) {
};

pub const address_space = struct {
pub const default = 0;
pub const default: c_uint = 0;

// See llvm/lib/Target/X86/X86.h
pub const x86_64 = x86;
pub const x86 = struct {
pub const gs = 256;
pub const fs = 257;
pub const ss = 258;
pub const gs: c_uint = 256;
pub const fs: c_uint = 257;
pub const ss: c_uint = 258;

pub const ptr32_sptr = 270;
pub const ptr32_uptr = 271;
pub const ptr64 = 272;
pub const ptr32_sptr: c_uint = 270;
pub const ptr32_uptr: c_uint = 271;
pub const ptr64: c_uint = 272;
};

// See llvm/lib/Target/AVR/AVR.h
pub const avr = struct {
pub const data_memory = 0;
pub const program_memory = 1;
pub const data_memory: c_uint = 0;
pub const program_memory: c_uint = 1;
};

// See llvm/lib/Target/NVPTX/NVPTX.h
pub const nvptx = struct {
pub const generic = 0;
pub const global = 1;
pub const constant = 2;
pub const shared = 3;
pub const param = 4;
pub const local = 5;
pub const generic: c_uint = 0;
pub const global: c_uint = 1;
pub const constant: c_uint = 2;
pub const shared: c_uint = 3;
pub const param: c_uint = 4;
pub const local: c_uint = 5;
};

// See llvm/lib/Target/AMDGPU/AMDGPU.h
pub const amdgpu = struct {
pub const flat = 0;
pub const global = 1;
pub const region = 2;
pub const local = 3;
pub const constant = 4;
pub const constant_32bit = 6;
pub const buffer_fat_pointer = 7;
pub const param_d = 6;
pub const param_i = 7;
pub const constant_buffer_0 = 8;
pub const constant_buffer_1 = 9;
pub const constant_buffer_2 = 10;
pub const constant_buffer_3 = 11;
pub const constant_buffer_4 = 12;
pub const constant_buffer_5 = 13;
pub const constant_buffer_6 = 14;
pub const constant_buffer_7 = 15;
pub const constant_buffer_8 = 16;
pub const constant_buffer_9 = 17;
pub const constant_buffer_10 = 18;
pub const constant_buffer_11 = 19;
pub const constant_buffer_12 = 20;
pub const constant_buffer_13 = 21;
pub const constant_buffer_14 = 22;
pub const constant_buffer_15 = 23;
pub const flat: c_uint = 0;
pub const global: c_uint = 1;
pub const region: c_uint = 2;
pub const local: c_uint = 3;
pub const constant: c_uint = 4;
pub const private: c_uint = 5;
pub const constant_32bit: c_uint = 6;
pub const buffer_fat_pointer: c_uint = 7;
pub const param_d: c_uint = 6;
pub const param_i: c_uint = 7;
pub const constant_buffer_0: c_uint = 8;
pub const constant_buffer_1: c_uint = 9;
pub const constant_buffer_2: c_uint = 10;
pub const constant_buffer_3: c_uint = 11;
pub const constant_buffer_4: c_uint = 12;
pub const constant_buffer_5: c_uint = 13;
pub const constant_buffer_6: c_uint = 14;
pub const constant_buffer_7: c_uint = 15;
pub const constant_buffer_8: c_uint = 16;
pub const constant_buffer_9: c_uint = 17;
pub const constant_buffer_10: c_uint = 18;
pub const constant_buffer_11: c_uint = 19;
pub const constant_buffer_12: c_uint = 20;
pub const constant_buffer_13: c_uint = 21;
pub const constant_buffer_14: c_uint = 22;
pub const constant_buffer_15: c_uint = 23;
};
};

0 comments on commit a56ea37

Please sign in to comment.