summaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCBranchSelector.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-13 17:56:02 +0000
committerChris Lattner <sabre@nondot.org>2006-10-13 17:56:02 +0000
commiteea52d3297c4c59e62b10477a3ebd1895430b508 (patch)
treeee512b672e7a9b73da16b27f136da1dd7b672ff0 /lib/Target/PowerPC/PPCBranchSelector.cpp
parent4c7b07a66f3d5c14339a6181fa12d060aeb9b18c (diff)
downloadllvm-eea52d3297c4c59e62b10477a3ebd1895430b508.tar.gz
llvm-eea52d3297c4c59e62b10477a3ebd1895430b508.tar.bz2
llvm-eea52d3297c4c59e62b10477a3ebd1895430b508.tar.xz
Correctly handle instruction separators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCBranchSelector.cpp')
-rw-r--r--lib/Target/PowerPC/PPCBranchSelector.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/Target/PowerPC/PPCBranchSelector.cpp b/lib/Target/PowerPC/PPCBranchSelector.cpp
index 5804c1adfc..10efb9882a 100644
--- a/lib/Target/PowerPC/PPCBranchSelector.cpp
+++ b/lib/Target/PowerPC/PPCBranchSelector.cpp
@@ -20,12 +20,15 @@
#include "PPCInstrInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetAsmInfo.h"
#include <map>
using namespace llvm;
namespace {
struct VISIBILITY_HIDDEN PPCBSel : public MachineFunctionPass {
- // OffsetMap - Mapping between BB and byte offset from start of function
+ /// OffsetMap - Mapping between BB and byte offset from start of function.
+ /// TODO: replace this with a vector, using the MBB idx as the key.
std::map<MachineBasicBlock*, unsigned> OffsetMap;
virtual bool runOnMachineFunction(MachineFunction &Fn);
@@ -55,20 +58,14 @@ static unsigned getNumBytesForInstruction(MachineInstr *MI) {
return 8;
case PPC::IMPLICIT_DEF_GPRC: // no asm emitted
case PPC::IMPLICIT_DEF_G8RC: // no asm emitted
- case PPC::IMPLICIT_DEF_F4: // no asm emitted
- case PPC::IMPLICIT_DEF_F8: // no asm emitted
+ case PPC::IMPLICIT_DEF_F4: // no asm emitted
+ case PPC::IMPLICIT_DEF_F8: // no asm emitted
return 0;
- case PPC::INLINEASM: // Inline Asm: Variable size.
- for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
- if (MI->getOperand(i).isExternalSymbol()) {
- const char *AsmStr = MI->getOperand(i).getSymbolName();
- // Count the number of newline's in the asm string.
- unsigned NumInstrs = 0;
- for (; *AsmStr; ++AsmStr)
- NumInstrs += *AsmStr == '\n';
- return NumInstrs*4;
- }
- assert(0 && "INLINEASM didn't have format string??");
+ case PPC::INLINEASM: { // Inline Asm: Variable size.
+ MachineFunction *MF = MI->getParent()->getParent();
+ const char *AsmStr = MI->getOperand(0).getSymbolName();
+ return MF->getTarget().getTargetAsmInfo()->getInlineAsmLength(AsmStr);
+ }
default:
return 4; // PowerPC instructions are all 4 bytes
}