forked from OSchip/llvm-project
[ARM64] Move CPSRField and DBarrier operands over to AArch64-style disassembly and assembly. This removes the last users of namespace ARM64SYS.
llvm-svn: 205869
This commit is contained in:
parent
08c391c156
commit
fb90df563f
|
@ -189,13 +189,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SystemRegisterOp {
|
struct SystemRegisterOp {
|
||||||
// 16-bit immediate, usually from the ARM64SYS::SystermRegister enum,
|
// 16-bit immediate, usually from the ARM64SysReg::SysRegValues enum
|
||||||
// but not limited to those values.
|
// but not limited to those values.
|
||||||
uint16_t Val;
|
uint16_t Val;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CPSRFieldOp {
|
struct CPSRFieldOp {
|
||||||
ARM64SYS::CPSRField Field;
|
ARM64PState::PStateValues Field;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SysCRImmOp {
|
struct SysCRImmOp {
|
||||||
|
@ -336,7 +336,7 @@ public:
|
||||||
return SystemRegister.Val;
|
return SystemRegister.Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARM64SYS::CPSRField getCPSRField() const {
|
ARM64PState::PStateValues getCPSRField() const {
|
||||||
assert(Kind == k_CPSRField && "Invalid access!");
|
assert(Kind == k_CPSRField && "Invalid access!");
|
||||||
return CPSRField.Field;
|
return CPSRField.Field;
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
// SPSel is legal for both the system register and the CPSR-field
|
// SPSel is legal for both the system register and the CPSR-field
|
||||||
// variants of MSR, so special case that. Fugly.
|
// variants of MSR, so special case that. Fugly.
|
||||||
return (Kind == k_CPSRField && getCPSRField() == ARM64SYS::cpsr_SPSel);
|
return (Kind == k_CPSRField && getCPSRField() == ARM64PState::SPSel);
|
||||||
}
|
}
|
||||||
bool isSystemCPSRField() const { return Kind == k_CPSRField; }
|
bool isSystemCPSRField() const { return Kind == k_CPSRField; }
|
||||||
bool isReg() const { return Kind == k_Register && !Reg.isVector; }
|
bool isReg() const { return Kind == k_Register && !Reg.isVector; }
|
||||||
|
@ -1285,8 +1285,8 @@ public:
|
||||||
if (Kind == k_SystemRegister)
|
if (Kind == k_SystemRegister)
|
||||||
Inst.addOperand(MCOperand::CreateImm(getSystemRegister()));
|
Inst.addOperand(MCOperand::CreateImm(getSystemRegister()));
|
||||||
else {
|
else {
|
||||||
assert(Kind == k_CPSRField && getCPSRField() == ARM64SYS::cpsr_SPSel);
|
assert(Kind == k_CPSRField && getCPSRField() == ARM64PState::SPSel);
|
||||||
Inst.addOperand(MCOperand::CreateImm(ARM64SYS::SPSel));
|
Inst.addOperand(MCOperand::CreateImm(ARM64SysReg::SPSel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1615,7 +1615,7 @@ public:
|
||||||
return Op;
|
return Op;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ARM64Operand *CreateCPSRField(ARM64SYS::CPSRField Field, SMLoc S,
|
static ARM64Operand *CreateCPSRField(ARM64PState::PStateValues Field, SMLoc S,
|
||||||
MCContext &Ctx) {
|
MCContext &Ctx) {
|
||||||
ARM64Operand *Op = new ARM64Operand(k_CPSRField, Ctx);
|
ARM64Operand *Op = new ARM64Operand(k_CPSRField, Ctx);
|
||||||
Op->CPSRField.Field = Field;
|
Op->CPSRField.Field = Field;
|
||||||
|
@ -1703,30 +1703,32 @@ void ARM64Operand::print(raw_ostream &OS) const {
|
||||||
<< ") >";
|
<< ") >";
|
||||||
break;
|
break;
|
||||||
case k_Barrier: {
|
case k_Barrier: {
|
||||||
const char *Name =
|
bool Valid;
|
||||||
ARM64SYS::getBarrierOptName((ARM64SYS::BarrierOption)getBarrier());
|
StringRef Name = ARM64DB::DBarrierMapper().toString(getBarrier(), Valid);
|
||||||
OS << "<barrier ";
|
if (Valid)
|
||||||
if (Name)
|
OS << "<barrier " << Name << ">";
|
||||||
OS << Name;
|
|
||||||
else
|
else
|
||||||
OS << getBarrier();
|
OS << "<barrier invalid #" << getCPSRField() << ">";
|
||||||
OS << ">";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case k_SystemRegister: {
|
case k_SystemRegister: {
|
||||||
const char *Name = ARM64SYS::getSystemRegisterName(
|
bool Valid;
|
||||||
(ARM64SYS::SystemRegister)getSystemRegister());
|
StringRef Name = ARM64SysReg::MRSMapper().toString(getSystemRegister(), Valid);
|
||||||
OS << "<systemreg ";
|
if (!Valid)
|
||||||
if (Name)
|
Name = ARM64SysReg::MSRMapper().toString(getSystemRegister(), Valid);
|
||||||
OS << Name;
|
if (Valid)
|
||||||
|
OS << "<systemreg " << Name << ">";
|
||||||
else
|
else
|
||||||
OS << "#" << getSystemRegister();
|
OS << "<systemreg invalid #" << getSystemRegister() << ">";
|
||||||
OS << ">";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case k_CPSRField: {
|
case k_CPSRField: {
|
||||||
const char *Name = ARM64SYS::getCPSRFieldName(getCPSRField());
|
bool Valid;
|
||||||
|
StringRef Name = ARM64PState::PStateMapper().toString(getCPSRField(), Valid);
|
||||||
|
if (Valid)
|
||||||
OS << "<cpsrfield " << Name << ">";
|
OS << "<cpsrfield " << Name << ">";
|
||||||
|
else
|
||||||
|
OS << "<cpsrfield invalid #" << getCPSRField() << ">";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case k_Immediate:
|
case k_Immediate:
|
||||||
|
@ -2601,27 +2603,15 @@ ARM64AsmParser::tryParseBarrierOperand(OperandVector &Operands) {
|
||||||
return MatchOperand_ParseFail;
|
return MatchOperand_ParseFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Opt = StringSwitch<unsigned>(Tok.getString())
|
bool Valid;
|
||||||
.Case("oshld", ARM64SYS::OSHLD)
|
unsigned Opt = ARM64DB::DBarrierMapper().fromString(Tok.getString(), Valid);
|
||||||
.Case("oshst", ARM64SYS::OSHST)
|
if (!Valid) {
|
||||||
.Case("osh", ARM64SYS::OSH)
|
|
||||||
.Case("nshld", ARM64SYS::NSHLD)
|
|
||||||
.Case("nshst", ARM64SYS::NSHST)
|
|
||||||
.Case("nsh", ARM64SYS::NSH)
|
|
||||||
.Case("ishld", ARM64SYS::ISHLD)
|
|
||||||
.Case("ishst", ARM64SYS::ISHST)
|
|
||||||
.Case("ish", ARM64SYS::ISH)
|
|
||||||
.Case("ld", ARM64SYS::LD)
|
|
||||||
.Case("st", ARM64SYS::ST)
|
|
||||||
.Case("sy", ARM64SYS::SY)
|
|
||||||
.Default(ARM64SYS::InvalidBarrier);
|
|
||||||
if (Opt == ARM64SYS::InvalidBarrier) {
|
|
||||||
TokError("invalid barrier option name");
|
TokError("invalid barrier option name");
|
||||||
return MatchOperand_ParseFail;
|
return MatchOperand_ParseFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The only valid named option for ISB is 'sy'
|
// The only valid named option for ISB is 'sy'
|
||||||
if (Mnemonic == "isb" && Opt != ARM64SYS::SY) {
|
if (Mnemonic == "isb" && Opt != ARM64DB::SY) {
|
||||||
TokError("'sy' or #imm operand expected");
|
TokError("'sy' or #imm operand expected");
|
||||||
return MatchOperand_ParseFail;
|
return MatchOperand_ParseFail;
|
||||||
}
|
}
|
||||||
|
@ -2683,13 +2673,11 @@ ARM64AsmParser::tryParseCPSRField(OperandVector &Operands) {
|
||||||
if (Tok.isNot(AsmToken::Identifier))
|
if (Tok.isNot(AsmToken::Identifier))
|
||||||
return MatchOperand_NoMatch;
|
return MatchOperand_NoMatch;
|
||||||
|
|
||||||
ARM64SYS::CPSRField Field =
|
bool Valid;
|
||||||
StringSwitch<ARM64SYS::CPSRField>(Tok.getString().lower())
|
ARM64PState::PStateValues Field = (ARM64PState::PStateValues)
|
||||||
.Case("spsel", ARM64SYS::cpsr_SPSel)
|
ARM64PState::PStateMapper().fromString(Tok.getString(), Valid);
|
||||||
.Case("daifset", ARM64SYS::cpsr_DAIFSet)
|
|
||||||
.Case("daifclr", ARM64SYS::cpsr_DAIFClr)
|
if (!Valid)
|
||||||
.Default(ARM64SYS::InvalidCPSRField);
|
|
||||||
if (Field == ARM64SYS::InvalidCPSRField)
|
|
||||||
return MatchOperand_NoMatch;
|
return MatchOperand_NoMatch;
|
||||||
Operands.push_back(
|
Operands.push_back(
|
||||||
ARM64Operand::CreateCPSRField(Field, getLoc(), getContext()));
|
ARM64Operand::CreateCPSRField(Field, getLoc(), getContext()));
|
||||||
|
|
|
@ -1387,8 +1387,10 @@ void ARM64InstPrinter::printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
||||||
void ARM64InstPrinter::printBarrierOption(const MCInst *MI, unsigned OpNo,
|
void ARM64InstPrinter::printBarrierOption(const MCInst *MI, unsigned OpNo,
|
||||||
raw_ostream &O) {
|
raw_ostream &O) {
|
||||||
unsigned Val = MI->getOperand(OpNo).getImm();
|
unsigned Val = MI->getOperand(OpNo).getImm();
|
||||||
const char *Name = ARM64SYS::getBarrierOptName((ARM64SYS::BarrierOption)Val);
|
|
||||||
if (Name)
|
bool Valid;
|
||||||
|
StringRef Name = ARM64DB::DBarrierMapper().toString(Val, Valid);
|
||||||
|
if (Valid)
|
||||||
O << Name;
|
O << Name;
|
||||||
else
|
else
|
||||||
O << "#" << Val;
|
O << "#" << Val;
|
||||||
|
@ -1421,8 +1423,13 @@ void ARM64InstPrinter::printMSRSystemRegister(const MCInst *MI, unsigned OpNo,
|
||||||
void ARM64InstPrinter::printSystemCPSRField(const MCInst *MI, unsigned OpNo,
|
void ARM64InstPrinter::printSystemCPSRField(const MCInst *MI, unsigned OpNo,
|
||||||
raw_ostream &O) {
|
raw_ostream &O) {
|
||||||
unsigned Val = MI->getOperand(OpNo).getImm();
|
unsigned Val = MI->getOperand(OpNo).getImm();
|
||||||
const char *Name = ARM64SYS::getCPSRFieldName((ARM64SYS::CPSRField)Val);
|
|
||||||
O << Name;
|
bool Valid;
|
||||||
|
StringRef Name = ARM64PState::PStateMapper().toString(Val, Valid);
|
||||||
|
if (Valid)
|
||||||
|
O << StringRef(Name.str()).upper();
|
||||||
|
else
|
||||||
|
O << "#" << Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARM64InstPrinter::printSIMDType10Operand(const MCInst *MI, unsigned OpNo,
|
void ARM64InstPrinter::printSIMDType10Operand(const MCInst *MI, unsigned OpNo,
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
# CHECK: sys #2, c0, c5, #7
|
# CHECK: sys #2, c0, c5, #7
|
||||||
# CHECK: sys #7, c6, c10, #7, x7
|
# CHECK: sys #7, c6, c10, #7, x7
|
||||||
# CHECK: sysl x20, #6, c3, c15, #7
|
# CHECK: sysl x20, #6, c3, c15, #7
|
||||||
# CHECK: msr SPSel, #0
|
# CHECK: msr SPSEL, #0
|
||||||
# CHECK: msr S3_0_C11_C0_0, x0
|
# CHECK: msr S3_0_C11_C0_0, x0
|
||||||
# CHECK: mrs x0, S3_0_C11_C0_0
|
# CHECK: mrs x0, S3_0_C11_C0_0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue