diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-12-30 22:31:56 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-12-30 21:41:02 -0800 |
| commit | 3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5 (patch) | |
| tree | a577bd97edf5d5da357d576c777861d443210aec /src/llvm_backend.zig | |
| parent | 133da8692e80532797dd91b32539cf2175280a95 (diff) | |
| download | zig-3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5.tar.gz zig-3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5.zip | |
stage2: rework Value Payload layout
This is the same as the previous commit but for Value instead of Type.
Add `Value.castTag` and note that it is preferable to call than
`Value.cast`. This matches other abstractions in the codebase.
Added a convenience function `Value.Tag.create` which really cleans up
the callsites of creating `Value` objects.
`Value` tags can now share payload types. This is in preparation for
another improvement that I want to do.
Diffstat (limited to 'src/llvm_backend.zig')
| -rw-r--r-- | src/llvm_backend.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/llvm_backend.zig b/src/llvm_backend.zig index 77aa4d3bd5..294e6f5400 100644 --- a/src/llvm_backend.zig +++ b/src/llvm_backend.zig @@ -280,7 +280,7 @@ pub const LLVMIRModule = struct { fn gen(self: *LLVMIRModule, module: *Module, typed_value: TypedValue, src: usize) !void { switch (typed_value.ty.zigTypeTag()) { .Fn => { - const func = typed_value.val.cast(Value.Payload.Function).?.func; + const func = typed_value.val.castTag(.function).?.data; const llvm_func = try self.resolveLLVMFunction(func); @@ -314,9 +314,9 @@ pub const LLVMIRModule = struct { } fn genCall(self: *LLVMIRModule, inst: *Inst.Call) !void { - if (inst.func.cast(Inst.Constant)) |func_inst| { - if (func_inst.val.cast(Value.Payload.Function)) |func_val| { - const func = func_val.func; + if (inst.func.value()) |func_value| { + if (func_value.castTag(.function)) |func_payload| { + const func = func_payload.data; const zig_fn_type = func.owner_decl.typed_value.most_recent.typed_value.ty; const llvm_fn = try self.resolveLLVMFunction(func); |
