-/// getNumBytesForInstruction - Return the number of bytes of code the specified
-/// instruction may be. This returns the maximum number of bytes.
-///
-static unsigned getNumBytesForInstruction(MachineInstr *MI) {
- switch (MI->getOpcode()) {
- case PPC::COND_BRANCH:
- // while this will be 4 most of the time, if we emit 8 it is just a
- // minor pessimization that saves us from having to worry about
- // keeping the offsets up to date later when we emit long branch glue.
- 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
- 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??");
- default:
- return 4; // PowerPC instructions are all 4 bytes
- }
-}
-
-