diff options
author | Nicolas Geoffray <nicolas.geoffray@lip6.fr> | 2008-04-16 20:10:13 +0000 |
---|---|---|
committer | Nicolas Geoffray <nicolas.geoffray@lip6.fr> | 2008-04-16 20:10:13 +0000 |
commit | cb162a0601c07804318bea53afe3f10f87567ef0 (patch) | |
tree | 17e026641b730ae73981f77df025c5543c674201 /lib/Target/PowerPC/PPCInstrInfo.cpp | |
parent | b6992de7fe6531839dcc66c5add607bf3975c9e2 (diff) | |
download | external_llvm-cb162a0601c07804318bea53afe3f10f87567ef0.zip external_llvm-cb162a0601c07804318bea53afe3f10f87567ef0.tar.gz external_llvm-cb162a0601c07804318bea53afe3f10f87567ef0.tar.bz2 |
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
Diffstat (limited to 'lib/Target/PowerPC/PPCInstrInfo.cpp')
-rw-r--r-- | lib/Target/PowerPC/PPCInstrInfo.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCInstrInfo.cpp b/lib/Target/PowerPC/PPCInstrInfo.cpp index ff7d42e..27ff767 100644 --- a/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -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 + } +} |