2005-07-01 22:44:09 +00:00
|
|
|
//===-- X86AsmPrinter.h - Convert X86 LLVM code to Intel assembly ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file the shared super class printer that converts from our internal
|
|
|
|
// representation of machine-dependent LLVM code to Intel and AT&T format
|
|
|
|
// assembly language. This printer is the output mechanism used by `llc'.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef X86ASMPRINTER_H
|
|
|
|
#define X86ASMPRINTER_H
|
|
|
|
|
|
|
|
#include "X86.h"
|
2006-09-20 22:03:51 +00:00
|
|
|
#include "X86MachineFunctionInfo.h"
|
2006-03-13 23:20:37 +00:00
|
|
|
#include "X86TargetMachine.h"
|
2005-07-01 22:44:09 +00:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2006-03-07 02:02:57 +00:00
|
|
|
#include "llvm/CodeGen/DwarfWriter.h"
|
2007-01-26 21:22:28 +00:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
2006-12-06 18:14:47 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2005-07-08 00:23:26 +00:00
|
|
|
#include <set>
|
|
|
|
|
2005-07-01 22:44:09 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2006-09-06 18:34:40 +00:00
|
|
|
struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter {
|
|
|
|
DwarfWriter DW;
|
2007-09-11 08:27:17 +00:00
|
|
|
MachineModuleInfo *MMI;
|
2006-03-07 02:02:57 +00:00
|
|
|
|
2006-09-06 18:34:40 +00:00
|
|
|
X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM,
|
2006-09-07 22:06:40 +00:00
|
|
|
const TargetAsmInfo *T)
|
2007-09-11 08:27:17 +00:00
|
|
|
: AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) {
|
2006-05-25 21:59:08 +00:00
|
|
|
Subtarget = &TM.getSubtarget<X86Subtarget>();
|
|
|
|
}
|
2005-07-01 22:44:09 +00:00
|
|
|
|
2006-09-20 22:03:51 +00:00
|
|
|
// We have to propagate some information about MachineFunction to
|
|
|
|
// AsmPrinter. It's ok, when we're printing the function, since we have
|
2006-09-26 03:57:53 +00:00
|
|
|
// access to MachineFunction and can get the appropriate MachineFunctionInfo.
|
2006-09-20 22:03:51 +00:00
|
|
|
// Unfortunately, this is not possible when we're printing reference to
|
|
|
|
// Function (e.g. calling it and so on). Even more, there is no way to get the
|
|
|
|
// corresponding MachineFunctions: it can even be not created at all. That's
|
|
|
|
// why we should use additional structure, when we're collecting all necessary
|
|
|
|
// information.
|
2006-09-26 03:57:53 +00:00
|
|
|
//
|
2006-09-20 22:03:51 +00:00
|
|
|
// This structure is using e.g. for name decoration for stdcall & fastcall'ed
|
|
|
|
// function, since we have to use arguments' size for decoration.
|
2007-04-17 17:21:52 +00:00
|
|
|
typedef std::map<const Function*, X86MachineFunctionInfo> FMFInfoMap;
|
2006-09-20 22:03:51 +00:00
|
|
|
FMFInfoMap FunctionInfoMap;
|
|
|
|
|
|
|
|
void decorateName(std::string& Name, const GlobalValue* GV);
|
|
|
|
|
2005-07-01 22:44:09 +00:00
|
|
|
bool doInitialization(Module &M);
|
|
|
|
bool doFinalization(Module &M);
|
|
|
|
|
2006-03-07 02:02:57 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
2006-10-31 08:31:24 +00:00
|
|
|
if (Subtarget->isTargetDarwin() ||
|
|
|
|
Subtarget->isTargetELF() ||
|
2007-01-03 11:43:14 +00:00
|
|
|
Subtarget->isTargetCygMing()) {
|
2007-01-26 21:22:28 +00:00
|
|
|
AU.addRequired<MachineModuleInfo>();
|
2006-07-27 01:12:23 +00:00
|
|
|
}
|
2007-09-30 13:39:29 +00:00
|
|
|
AsmPrinter::getAnalysisUsage(AU);
|
2006-03-07 02:02:57 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 21:59:08 +00:00
|
|
|
const X86Subtarget *Subtarget;
|
2005-07-01 22:44:09 +00:00
|
|
|
|
2005-07-08 00:23:26 +00:00
|
|
|
// Necessary for Darwin to print out the apprioriate types of linker stubs
|
|
|
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
|
|
|
|
2006-09-14 18:23:27 +00:00
|
|
|
// Necessary for dllexport support
|
|
|
|
std::set<std::string> DLLExportedFns, DLLExportedGVs;
|
2006-12-01 00:25:12 +00:00
|
|
|
|
2005-07-01 22:44:09 +00:00
|
|
|
inline static bool isScale(const MachineOperand &MO) {
|
|
|
|
return MO.isImmediate() &&
|
|
|
|
(MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
|
|
|
|
MO.getImmedValue() == 4 || MO.getImmedValue() == 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static bool isMem(const MachineInstr *MI, unsigned Op) {
|
|
|
|
if (MI->getOperand(Op).isFrameIndex()) return true;
|
|
|
|
return Op+4 <= MI->getNumOperands() &&
|
|
|
|
MI->getOperand(Op ).isRegister() && isScale(MI->getOperand(Op+1)) &&
|
2006-02-25 09:56:50 +00:00
|
|
|
MI->getOperand(Op+2).isRegister() &&
|
|
|
|
(MI->getOperand(Op+3).isImmediate() ||
|
|
|
|
MI->getOperand(Op+3).isGlobalAddress() ||
|
2006-08-29 22:14:48 +00:00
|
|
|
MI->getOperand(Op+3).isConstantPoolIndex() ||
|
|
|
|
MI->getOperand(Op+3).isJumpTableIndex());
|
2005-07-01 22:44:09 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|