mirror of
https://github.com/ziglang/zig.git
synced 2025-12-13 17:53:07 +00:00
AstGen: don't coerce inputs to usize in asmExpr
Instead, use ResultLoc.none to allow for the expression type to be
inferred [^1]. This effectively moves the type coercion to Sema, in
order to turn comptime values into usable values for the backends to
consume. Right now the coercion is applies as comptime_int -> usize and
comptime_float -> f64, as an arbitrary choice.
[^1]: 9f25c8140c/src/AstGen.zig (L207-L208)
This commit is contained in:
parent
633fe41a2c
commit
ebafdb958c
@ -6842,7 +6842,7 @@ fn asmExpr(
|
||||
const name = try astgen.identAsString(symbolic_name);
|
||||
const constraint_token = symbolic_name + 2;
|
||||
const constraint = (try astgen.strLitAsString(constraint_token)).index;
|
||||
const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs);
|
||||
const operand = try expr(gz, scope, .none, node_datas[input_node].lhs);
|
||||
inputs[i] = .{
|
||||
.name = name,
|
||||
.constraint = constraint,
|
||||
|
||||
@ -10304,7 +10304,14 @@ fn zirAsm(
|
||||
const name = sema.code.nullTerminatedString(input.data.name);
|
||||
_ = name; // TODO: use the name
|
||||
|
||||
arg.* = sema.resolveInst(input.data.operand);
|
||||
const uncasted_arg = sema.resolveInst(input.data.operand);
|
||||
const uncasted_arg_ty = sema.typeOf(uncasted_arg);
|
||||
switch (uncasted_arg_ty.zigTypeTag()) {
|
||||
.ComptimeInt => arg.* = try sema.coerce(block, Type.initTag(.usize), uncasted_arg, src),
|
||||
.ComptimeFloat => arg.* = try sema.coerce(block, Type.initTag(.f64), uncasted_arg, src),
|
||||
else => arg.* = uncasted_arg,
|
||||
}
|
||||
|
||||
const constraint = sema.code.nullTerminatedString(input.data.constraint);
|
||||
needed_capacity += constraint.len / 4 + 1;
|
||||
inputs[arg_i] = constraint;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user