aboutsummaryrefslogtreecommitdiff
path: root/src/AstGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-27 16:45:23 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-04-27 16:45:23 -0700
commit09f1d62bdfb5794534b21d1cd9dafc4822697d60 (patch)
tree437f6c19a6f0f16ef29fb91513176bb8aa0c91f0 /src/AstGen.zig
parentc4eaff6665132287d05272bef8890e4607ff017c (diff)
downloadzig-09f1d62bdfb5794534b21d1cd9dafc4822697d60.tar.gz
zig-09f1d62bdfb5794534b21d1cd9dafc4822697d60.zip
add new builtin function `@tan`
The reason for having `@tan` is that we already have `@sin` and `@cos` because some targets have machine code instructions for them, but in the case that the implementation needs to go into compiler-rt, sin, cos, and tan all share a common dependency which includes a table of data. To avoid duplicating this table of data, we promote tan to become a builtin alongside sin and cos. ZIR: The tag enum is at capacity so this commit moves `field_call_bind_named` to be `extended`. I measured this as one of the least used tags in the zig codebase. Fix libc math suffix for `f32` being wrong in both stage1 and stage2. stage1: add missing libc prefix for float functions.
Diffstat (limited to 'src/AstGen.zig')
-rw-r--r--src/AstGen.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 34b29b28fb..230b46a489 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -2237,7 +2237,6 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
.field_call_bind,
.field_ptr_named,
.field_val_named,
- .field_call_bind_named,
.func,
.func_inferred,
.int,
@@ -2329,6 +2328,7 @@ fn unusedResultExpr(gz: *GenZir, scope: *Scope, statement: Ast.Node.Index) Inner
.sqrt,
.sin,
.cos,
+ .tan,
.exp,
.exp2,
.log,
@@ -7259,6 +7259,7 @@ fn builtinCall(
.sqrt => return simpleUnOp(gz, scope, rl, node, .none, params[0], .sqrt),
.sin => return simpleUnOp(gz, scope, rl, node, .none, params[0], .sin),
.cos => return simpleUnOp(gz, scope, rl, node, .none, params[0], .cos),
+ .tan => return simpleUnOp(gz, scope, rl, node, .none, params[0], .tan),
.exp => return simpleUnOp(gz, scope, rl, node, .none, params[0], .exp),
.exp2 => return simpleUnOp(gz, scope, rl, node, .none, params[0], .exp2),
.log => return simpleUnOp(gz, scope, rl, node, .none, params[0], .log),
@@ -7947,7 +7948,8 @@ fn calleeExpr(
if (std.mem.eql(u8, builtin_name, "@field") and params.len == 2) {
const lhs = try expr(gz, scope, .ref, params[0]);
const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);
- return gz.addPlNode(.field_call_bind_named, node, Zir.Inst.FieldNamed{
+ return gz.addExtendedPayload(.field_call_bind_named, Zir.Inst.FieldNamedNode{
+ .node = gz.nodeIndexToRelative(node),
.lhs = lhs,
.field_name = field_name,
});