llvm.org GIT mirror llvm / 4b46267
McARM: Use accessors where appropriate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123746 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 9 years ago
1 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
265265 bool isToken() const { return Kind == Token; }
266266 bool isMemory() const { return Kind == Memory; }
267267 bool isMemMode5() const {
268 if (!isMemory() || Mem.OffsetIsReg || Mem.OffsetRegShifted ||
269 Mem.Writeback || Mem.Negative)
268 if (!isMemory() || getMemOffsetIsReg() || getMemWriteback() ||
269 getMemNegative())
270270 return false;
271271
272 const MCConstantExpr *CE = dyn_cast(Mem.Offset.Value);
272 const MCConstantExpr *CE = dyn_cast(getMemOffset());
273273 if (!CE) return false;
274274
275275 // The offset must be a multiple of 4 in the range 0-1020.
277277 return ((Value & 0x3) == 0 && Value <= 1020 && Value >= -1020);
278278 }
279279 bool isMemModeRegThumb() const {
280 if (!isMemory() || !Mem.OffsetIsReg || Mem.Writeback)
280 if (!isMemory() || !getMemOffsetIsReg() || getMemWriteback())
281281 return false;
282282 return true;
283283 }
284284 bool isMemModeImmThumb() const {
285 if (!isMemory() || Mem.OffsetIsReg || Mem.Writeback)
285 if (!isMemory() || getMemOffsetIsReg() || getMemWriteback())
286286 return false;
287287
288 const MCConstantExpr *CE = dyn_cast(Mem.Offset.Value);
288 const MCConstantExpr *CE = dyn_cast(getMemOffset());
289289 if (!CE) return false;
290290
291291 // The offset must be a multiple of 4 in the range 0-124.
344344 void addMemMode5Operands(MCInst &Inst, unsigned N) const {
345345 assert(N == 2 && isMemMode5() && "Invalid number of operands!");
346346
347 Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum));
348 assert(!Mem.OffsetIsReg && "Invalid mode 5 operand");
347 Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum()));
348 assert(!getMemOffsetIsReg() && "Invalid mode 5 operand");
349349
350350 // FIXME: #-0 is encoded differently than #0. Does the parser preserve
351351 // the difference?
352 const MCConstantExpr *CE = dyn_cast(Mem.Offset.Value);
352 const MCConstantExpr *CE = dyn_cast(getMemOffset());
353353 assert(CE && "Non-constant mode 5 offset operand!");
354354
355355 // The MCInst offset operand doesn't include the low two bits (like
365365
366366 void addMemModeRegThumbOperands(MCInst &Inst, unsigned N) const {
367367 assert(N == 2 && isMemModeRegThumb() && "Invalid number of operands!");
368 Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum));
369 Inst.addOperand(MCOperand::CreateReg(Mem.Offset.RegNum));
368 Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum()));
369 Inst.addOperand(MCOperand::CreateReg(getMemOffsetRegNum()));
370370 }
371371
372372 void addMemModeImmThumbOperands(MCInst &Inst, unsigned N) const {
373373 assert(N == 2 && isMemModeImmThumb() && "Invalid number of operands!");
374 Inst.addOperand(MCOperand::CreateReg(Mem.BaseRegNum));
375 const MCConstantExpr *CE = dyn_cast(Mem.Offset.Value);
374 Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum()));
375 const MCConstantExpr *CE = dyn_cast(getMemOffset());
376376 assert(CE && "Non-constant mode offset operand!");
377377 Inst.addOperand(MCOperand::CreateImm(CE->getValue()));
378378 }