Skip to content

Commit

Permalink
[ARM64] Change SYS without a register to an alias to make disassembli…
Browse files Browse the repository at this point in the history
…ng more consistant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205898 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
brads55 committed Apr 9, 2014
1 parent 62293d1 commit 35fb92d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
16 changes: 0 additions & 16 deletions lib/Target/ARM64/ARM64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -774,22 +774,6 @@ def sys_cr_op : Operand<i32> {
let ParserMatchClass = SysCRAsmOperand;
}

class SystemI<bit L, string asm>
: SimpleSystemI<L,
(ins imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2),
asm, "\t$op1, $Cn, $Cm, $op2">,
Sched<[WriteSys]> {
bits<3> op1;
bits<4> Cn;
bits<4> Cm;
bits<3> op2;
let Inst{20-19} = 0b01;
let Inst{18-16} = op1;
let Inst{15-12} = Cn;
let Inst{11-8} = Cm;
let Inst{7-5} = op2;
}

class SystemXtI<bit L, string asm>
: RtSystemI<L, (outs),
(ins imm0_7:$op1, sys_cr_op:$Cn, sys_cr_op:$Cm, imm0_7:$op2, GPR64:$Rt),
Expand Down
5 changes: 4 additions & 1 deletion lib/Target/ARM64/ARM64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,13 @@ def MSRcpsr: MSRcpsrI;
def : Pat<(ARM64threadpointer), (MRS 0xde82)>;

// Generic system instructions
def SYS : SystemI<0, "sys">;
def SYSxt : SystemXtI<0, "sys">;
def SYSLxt : SystemLXtI<1, "sysl">;

def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
(SYSxt imm0_7:$op1, sys_cr_op:$Cn,
sys_cr_op:$Cm, imm0_7:$op2, XZR)>;

//===----------------------------------------------------------------------===//
// Move immediate instructions.
//===----------------------------------------------------------------------===//
Expand Down
11 changes: 6 additions & 5 deletions lib/Target/ARM64/InstPrinter/ARM64InstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void ARM64InstPrinter::printInst(const MCInst *MI, raw_ostream &O,

unsigned Opcode = MI->getOpcode();

if (Opcode == ARM64::SYS || Opcode == ARM64::SYSxt)
if (Opcode == ARM64::SYSxt)
if (printSysAlias(MI, O)) {
printAnnotation(O, Annot);
return;
Expand Down Expand Up @@ -750,8 +750,7 @@ void ARM64AppleInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
bool ARM64InstPrinter::printSysAlias(const MCInst *MI, raw_ostream &O) {
#ifndef NDEBUG
unsigned Opcode = MI->getOpcode();
assert((Opcode == ARM64::SYS || Opcode == ARM64::SYSxt) &&
"Invalid opcode for SYS alias!");
assert(Opcode == ARM64::SYSxt && "Invalid opcode for SYS alias!");
#endif

const char *Asm = 0;
Expand Down Expand Up @@ -961,9 +960,11 @@ bool ARM64InstPrinter::printSysAlias(const MCInst *MI, raw_ostream &O) {
}

if (Asm) {
unsigned Reg = MI->getOperand(4).getReg();

O << '\t' << Asm;
if (MI->getNumOperands() == 5)
O << ", " << getRegisterName(MI->getOperand(4).getReg());
if (StringRef(Asm).lower().find("all") == StringRef::npos)
O << ", " << getRegisterName(Reg);
}

return Asm != 0;
Expand Down
2 changes: 2 additions & 0 deletions test/MC/Disassembler/ARM64/system.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# CHECK: dmb osh
0x9f 0x37 0x03 0xd5
# CHECK: dsb nsh
0x3f 0x76 0x08 0xd5
# CHECK: dc ivac

#-----------------------------------------------------------------------------
# Generic system instructions
Expand Down

0 comments on commit 35fb92d

Please sign in to comment.