mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 05:22:04 +00:00
Infrastructure for getting the machine code size of a function and an instruction. X86, PowerPC and ARM are implemented
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49809 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
using namespace llvm;
|
||||
|
||||
extern cl::opt<bool> EnablePPC32RS; // FIXME (64-bit): See PPCRegisterInfo.cpp.
|
||||
@@ -724,3 +725,21 @@ ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
|
||||
Cond[0].setImm(PPC::InvertPredicate((PPC::Predicate)Cond[0].getImm()));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// GetInstSize - Return the number of bytes of code the specified
|
||||
/// instruction may be. This returns the maximum number of bytes.
|
||||
///
|
||||
unsigned PPCInstrInfo::GetInstSizeInBytes(const MachineInstr *MI) const {
|
||||
switch (MI->getOpcode()) {
|
||||
case PPC::INLINEASM: { // Inline Asm: Variable size.
|
||||
const MachineFunction *MF = MI->getParent()->getParent();
|
||||
const char *AsmStr = MI->getOperand(0).getSymbolName();
|
||||
return MF->getTarget().getTargetAsmInfo()->getInlineAsmLength(AsmStr);
|
||||
}
|
||||
case PPC::LABEL: {
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 4; // PowerPC instructions are all 4 bytes
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user