mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
c: support +r output constraint
This commit is contained in:
parent
2e341a7173
commit
e93ce49504
1 changed files with 10 additions and 8 deletions
|
|
@ -5478,14 +5478,16 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||||
// for the string, we still use the next u32 for the null terminator.
|
// for the string, we still use the next u32 for the null terminator.
|
||||||
extra_i += (constraint.len + name.len + (2 + 3)) / 4;
|
extra_i += (constraint.len + name.len + (2 + 3)) / 4;
|
||||||
|
|
||||||
if (constraint.len < 2 or constraint[0] != '=' or
|
// +constraint
|
||||||
(constraint[1] == '{' and constraint[constraint.len - 1] != '}'))
|
// =constraint
|
||||||
{
|
if (constraint.len > 1 and
|
||||||
return f.fail("CBE: constraint not supported: '{s}'", .{constraint});
|
(constraint[0] == '=' or constraint[0] == '+') and
|
||||||
}
|
constraint[1] != '{') continue;
|
||||||
|
|
||||||
const is_reg = constraint[1] == '{';
|
// ={reg}
|
||||||
if (is_reg) {
|
if (std.mem.startsWith(u8, constraint, "={") and
|
||||||
|
std.mem.endsWith(u8, constraint, "}"))
|
||||||
|
{
|
||||||
const output_ty = if (output == .none) inst_ty else f.typeOf(output).childType(zcu);
|
const output_ty = if (output == .none) inst_ty else f.typeOf(output).childType(zcu);
|
||||||
try w.writeAll("register ");
|
try w.writeAll("register ");
|
||||||
const output_local = try f.allocLocalValue(.{
|
const output_local = try f.allocLocalValue(.{
|
||||||
|
|
@ -5503,7 +5505,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||||
}
|
}
|
||||||
try w.writeByte(';');
|
try w.writeByte(';');
|
||||||
try f.object.newline();
|
try f.object.newline();
|
||||||
}
|
} else return f.fail("CBE: constraint not supported: '{s}'", .{constraint});
|
||||||
}
|
}
|
||||||
for (inputs) |input| {
|
for (inputs) |input| {
|
||||||
const extra_bytes = mem.sliceAsBytes(f.air.extra.items[extra_i..]);
|
const extra_bytes = mem.sliceAsBytes(f.air.extra.items[extra_i..]);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue