1 //===-- X86AsmPrinter.h - Convert X86 LLVM code to Intel assembly ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file the shared super class printer that converts from our internal
11 // representation of machine-dependent LLVM code to Intel and AT&T format
12 // assembly language. This printer is the output mechanism used by `llc'.
14 //===----------------------------------------------------------------------===//
16 #ifndef X86ASMPRINTER_H
17 #define X86ASMPRINTER_H
20 #include "llvm/CodeGen/AsmPrinter.h"
21 #include "llvm/ADT/Statistic.h"
28 extern Statistic<> EmittedInsts;
30 struct X86SharedAsmPrinter : public AsmPrinter {
31 X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
32 : AsmPrinter(O, TM), forDarwin(false) { }
34 bool doInitialization(Module &M);
35 bool doFinalization(Module &M);
37 bool forDarwin; // FIXME: eliminate.
39 // Necessary for Darwin to print out the apprioriate types of linker stubs
40 std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
42 inline static bool isScale(const MachineOperand &MO) {
43 return MO.isImmediate() &&
44 (MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
45 MO.getImmedValue() == 4 || MO.getImmedValue() == 8);
48 inline static bool isMem(const MachineInstr *MI, unsigned Op) {
49 if (MI->getOperand(Op).isFrameIndex()) return true;
50 if (MI->getOperand(Op).isConstantPoolIndex()) return true;
51 return Op+4 <= MI->getNumOperands() &&
52 MI->getOperand(Op ).isRegister() && isScale(MI->getOperand(Op+1)) &&
53 MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate()||
54 MI->getOperand(Op+3).isGlobalAddress());
58 } // end namespace x86
59 } // end namespace llvm