llvm.org GIT mirror llvm / cfe0724
More bits of the ARM target assembler for llvm-mc to parse immediates. Also fixed a couple of coding style things that crept in. And added more to the temporary hacked up ARMAsmParser::MatchInstruction() method for testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84040 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 11 years ago
1 changed file(s) with 28 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
9191 enum {
9292 Token,
9393 Register,
94 Immediate,
9495 Memory
9596 } Kind;
9697
105106 unsigned RegNum;
106107 bool Writeback;
107108 } Reg;
109
110 struct {
111 const MCExpr *Val;
112 } Imm;
108113
109114 // This is for all forms of ARM address expressions
110115 struct {
133138 return Reg.RegNum;
134139 }
135140
141 const MCExpr *getImm() const {
142 assert(Kind == Immediate && "Invalid access!");
143 return Imm.Val;
144 }
145
136146 bool isToken() const {return Kind == Token; }
137147
138148 bool isReg() const { return Kind == Register; }
155165 Res.Kind = Register;
156166 Res.Reg.RegNum = RegNum;
157167 Res.Reg.Writeback = Writeback;
168 return Res;
169 }
170
171 static ARMOperand CreateImm(const MCExpr *Val) {
172 ARMOperand Res;
173 Res.Kind = Immediate;
174 Res.Imm.Val = Val;
158175 return Res;
159176 }
160177
216233 // for now.
217234 bool ARMAsmParser::ParseRegisterList(ARMOperand &Op) {
218235 assert(getLexer().getTok().is(AsmToken::LCurly) &&
219 "Token is not an Left Curly Brace");
236 "Token is not an Left Curly Brace");
220237 getLexer().Lex(); // Eat left curly brace token.
221238
222239 const AsmToken &RegTok = getLexer().getTok();
497514 Mnemonic == "str" ||
498515 Mnemonic == "ldmfd" ||
499516 Mnemonic == "ldr" ||
500 Mnemonic == "mov")
517 Mnemonic == "mov" ||
518 Mnemonic == "sub")
501519 return false;
502520
503521 return true;
516534 return false;
517535 case AsmToken::LCurly:
518536 if (!ParseRegisterList(Op))
519 return(false);
537 return false;
520538 case AsmToken::Hash:
521 return Error(getLexer().getTok().getLoc(), "immediates not yet supported");
539 // $42 -> immediate.
540 getLexer().Lex();
541 const MCExpr *Val;
542 if (getParser().ParseExpression(Val))
543 return true;
544 Op = ARMOperand::CreateImm(Val);
545 return false;
522546 default:
523547 return Error(getLexer().getTok().getLoc(), "unexpected token in operand");
524548 }