llvm-mc/AsmParser: Implement user defined super classes.

- We can now discriminate SUB32ri8 from SUB32ri, for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78530 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-08-09 07:20:21 +00:00
parent 22cd2547fe
commit 5fe6338ac8
4 changed files with 113 additions and 12 deletions

View File

@@ -137,6 +137,19 @@ struct X86Operand {
bool isImm() const { return Kind == Immediate; }
bool isImmSExt8() const {
// Accept immediates which fit in 8 bits when sign extended, and
// non-absolute immediates.
if (!isImm())
return false;
if (!getImm().isAbsolute())
return true;
int64_t Value = getImm().getConstant();
return Value == (int64_t) (int8_t) Value;
}
bool isMem() const { return Kind == Memory; }
bool isReg() const { return Kind == Register; }
@@ -151,6 +164,12 @@ struct X86Operand {
Inst.addOperand(MCOperand::CreateMCValue(getImm()));
}
void addImmSExt8Operands(MCInst &Inst, unsigned N) {
// FIXME: Support user customization of the render method.
assert(N == 1 && "Invalid number of operands!");
Inst.addOperand(MCOperand::CreateMCValue(getImm()));
}
void addMemOperands(MCInst &Inst, unsigned N) {
assert((N == 4 || N == 5) && "Invalid number of operands!");