mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
cbe: fix more MIPS register names in inline assembly
This commit is contained in:
parent
95c76b1b4a
commit
a8fea09cd5
@ -5768,21 +5768,25 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
|
|||||||
switch (aggregate.storage) {
|
switch (aggregate.storage) {
|
||||||
.elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
|
.elems => |elems| for (elems, 0..) |elem, i| switch (elem) {
|
||||||
.bool_true => {
|
.bool_true => {
|
||||||
const name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
|
const field_name = struct_type.structFieldName(i, zcu).toSlice(ip).?;
|
||||||
assert(name.len != 0);
|
assert(field_name.len != 0);
|
||||||
|
|
||||||
const target = &f.object.dg.mod.resolved_target.result;
|
const target = &f.object.dg.mod.resolved_target.result;
|
||||||
if (target.cpu.arch.isMIPS() and name[0] == 'r') {
|
var c_name_buf: [16]u8 = undefined;
|
||||||
// GCC uses "$N" for register names instead of "rN" used by Zig.
|
const name =
|
||||||
var c_name_buf: [4]u8 = undefined;
|
if ((target.cpu.arch.isMIPS() or target.cpu.arch == .alpha) and field_name[0] == 'r') name: {
|
||||||
const c_name = (&c_name_buf)[0..name.len];
|
// Convert "rN" to "$N"
|
||||||
@memcpy(c_name, name);
|
const c_name = (&c_name_buf)[0..field_name.len];
|
||||||
c_name_buf[0] = '$';
|
@memcpy(c_name, field_name);
|
||||||
|
c_name_buf[0] = '$';
|
||||||
try w.print(" {f}", .{fmtStringLiteral(c_name, null)});
|
break :name c_name;
|
||||||
(try w.writableArray(1))[0] = ',';
|
} else if ((target.cpu.arch.isMIPS() and (mem.startsWith(u8, field_name, "fcc") or field_name[0] == 'w')) or
|
||||||
continue;
|
((target.cpu.arch.isMIPS() or target.cpu.arch == .alpha) and field_name[0] == 'f')) name: {
|
||||||
}
|
// "$" prefix for FCC, W and F registers
|
||||||
|
c_name_buf[0] = '$';
|
||||||
|
@memcpy((&c_name_buf)[1..][0..field_name.len], field_name);
|
||||||
|
break :name (&c_name_buf)[0 .. 1 + field_name.len];
|
||||||
|
} else field_name;
|
||||||
|
|
||||||
try w.print(" {f}", .{fmtStringLiteral(name, null)});
|
try w.print(" {f}", .{fmtStringLiteral(name, null)});
|
||||||
(try w.writableArray(1))[0] = ',';
|
(try w.writableArray(1))[0] = ',';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user