aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Target
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2010-04-07 12:21:42 -0700
committerShih-wei Liao <sliao@google.com>2010-04-07 12:21:42 -0700
commite4454320b3cfffe926a487c33fbeb454366de2f8 (patch)
tree133c05da684edf4a3b2529bcacfa996298c455f6 /include/llvm/Target
parent20570085304f0a4ab4f112a01d77958bbd2827a1 (diff)
downloadexternal_llvm-e4454320b3cfffe926a487c33fbeb454366de2f8.zip
external_llvm-e4454320b3cfffe926a487c33fbeb454366de2f8.tar.gz
external_llvm-e4454320b3cfffe926a487c33fbeb454366de2f8.tar.bz2
libbcc
Change-Id: Ieaa3ebd5a38f370752495549f8870b534eeedfc5
Diffstat (limited to 'include/llvm/Target')
-rw-r--r--include/llvm/Target/Mangler.h2
-rw-r--r--include/llvm/Target/Target.td7
-rw-r--r--include/llvm/Target/TargetAsmBackend.h35
-rw-r--r--include/llvm/Target/TargetAsmParser.h4
-rw-r--r--include/llvm/Target/TargetInstrInfo.h28
-rw-r--r--include/llvm/Target/TargetLowering.h11
-rw-r--r--include/llvm/Target/TargetLoweringObjectFile.h182
-rw-r--r--include/llvm/Target/TargetMachine.h43
-rw-r--r--include/llvm/Target/TargetOpcodes.h4
-rw-r--r--include/llvm/Target/TargetRegisterInfo.h11
-rw-r--r--include/llvm/Target/TargetRegistry.h205
-rw-r--r--include/llvm/Target/TargetSelectionDAG.td3
12 files changed, 227 insertions, 308 deletions
diff --git a/include/llvm/Target/Mangler.h b/include/llvm/Target/Mangler.h
index 04de4e9..45cbf9d 100644
--- a/include/llvm/Target/Mangler.h
+++ b/include/llvm/Target/Mangler.h
@@ -1,4 +1,4 @@
-//===-- llvm/Support/Mangler.h - Self-contained name mangler ----*- C++ -*-===//
+//===-- llvm/Target/Mangler.h - Self-contained name mangler ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td
index 9a117df..0cffffb 100644
--- a/include/llvm/Target/Target.td
+++ b/include/llvm/Target/Target.td
@@ -211,16 +211,9 @@ class Instruction {
// hasSideEffects - The instruction has side effects that are not
// captured by any operands of the instruction or other flags.
//
- // mayHaveSideEffects - Some instances of the instruction can have side
- // effects. The virtual method "isReallySideEffectFree" is called to
- // determine this. Load instructions are an example of where this is
- // useful. In general, loads always have side effects. However, loads from
- // constant pools don't. Individual back ends make this determination.
- //
// neverHasSideEffects - Set on an instruction with no pattern if it has no
// side effects.
bit hasSideEffects = 0;
- bit mayHaveSideEffects = 0;
bit neverHasSideEffects = 0;
// Is this instruction a "real" instruction (with a distinct machine
diff --git a/include/llvm/Target/TargetAsmBackend.h b/include/llvm/Target/TargetAsmBackend.h
new file mode 100644
index 0000000..dfdabdb
--- /dev/null
+++ b/include/llvm/Target/TargetAsmBackend.h
@@ -0,0 +1,35 @@
+//===-- llvm/Target/TargetAsmBackend.h - Target Asm Backend -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGET_TARGETASMBACKEND_H
+#define LLVM_TARGET_TARGETASMBACKEND_H
+
+namespace llvm {
+class Target;
+
+/// TargetAsmBackend - Generic interface to target specific assembler backends.
+class TargetAsmBackend {
+ TargetAsmBackend(const TargetAsmBackend &); // DO NOT IMPLEMENT
+ void operator=(const TargetAsmBackend &); // DO NOT IMPLEMENT
+protected: // Can only create subclasses.
+ TargetAsmBackend(const Target &);
+
+ /// TheTarget - The Target that this machine was created for.
+ const Target &TheTarget;
+
+public:
+ virtual ~TargetAsmBackend();
+
+ const Target &getTarget() const { return TheTarget; }
+
+};
+
+} // End llvm namespace
+
+#endif
diff --git a/include/llvm/Target/TargetAsmParser.h b/include/llvm/Target/TargetAsmParser.h
index da9ba2b..85315c1 100644
--- a/include/llvm/Target/TargetAsmParser.h
+++ b/include/llvm/Target/TargetAsmParser.h
@@ -42,8 +42,8 @@ public:
/// line should be parsed up to and including the end-of-statement token. On
/// failure, the parser is not required to read to the end of the line.
//
- /// \param AP - The current parser object.
/// \param Name - The instruction name.
+ /// \param NameLoc - The source location of the name.
/// \param Operands [out] - The list of parsed operands, this returns
/// ownership of them to the caller.
/// \return True on failure.
@@ -59,7 +59,7 @@ public:
/// the target, the entire line is parsed up to and including the
/// end-of-statement token and false is returned.
///
- /// \param ID - the identifier token of the directive.
+ /// \param DirectiveID - the identifier token of the directive.
virtual bool ParseDirective(AsmToken DirectiveID) = 0;
/// MatchInstruction - Recognize a series of operands of a parsed instruction
diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h
index d95e4e8..4b26beb 100644
--- a/include/llvm/Target/TargetInstrInfo.h
+++ b/include/llvm/Target/TargetInstrInfo.h
@@ -19,14 +19,14 @@
namespace llvm {
-class MCAsmInfo;
-class TargetRegisterClass;
-class TargetRegisterInfo;
-class LiveVariables;
class CalleeSavedInfo;
+class LiveVariables;
+class MCAsmInfo;
+class MachineMemOperand;
class SDNode;
class SelectionDAG;
-class MachineMemOperand;
+class TargetRegisterClass;
+class TargetRegisterInfo;
template<class T> class SmallVectorImpl;
@@ -243,13 +243,11 @@ public:
virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
unsigned &SrcOpIdx2) const = 0;
- /// isIdentical - Return true if two instructions are identical. This differs
- /// from MachineInstr::isIdenticalTo() in that it does not require the
- /// virtual destination registers to be the same. This is used by MachineLICM
- /// and other MI passes to perform CSE.
- virtual bool isIdentical(const MachineInstr *MI,
- const MachineInstr *Other,
- const MachineRegisterInfo *MRI) const = 0;
+ /// produceSameValue - Return true if two machine instructions would produce
+ /// identical values. By default, this is only true when the two instructions
+ /// are deemed identical except for defs.
+ virtual bool produceSameValue(const MachineInstr *MI0,
+ const MachineInstr *MI1) const = 0;
/// AnalyzeBranch - Analyze the branching code at the end of MBB, returning
/// true if it cannot be understood (e.g. it's a switch dispatch or isn't
@@ -560,10 +558,8 @@ public:
const TargetRegisterInfo *TRI) const;
virtual MachineInstr *duplicate(MachineInstr *Orig,
MachineFunction &MF) const;
- virtual bool isIdentical(const MachineInstr *MI,
- const MachineInstr *Other,
- const MachineRegisterInfo *MRI) const;
-
+ virtual bool produceSameValue(const MachineInstr *MI0,
+ const MachineInstr *MI1) const;
virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
};
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h
index e172edf..5bc1c0e 100644
--- a/include/llvm/Target/TargetLowering.h
+++ b/include/llvm/Target/TargetLowering.h
@@ -346,6 +346,11 @@ public:
return true;
}
+ /// canOpTrap - Returns true if the operation can trap for the value type.
+ /// VT must be a legal type. By default, we optimistically assume most
+ /// operations don't trap except for divide and remainder.
+ virtual bool canOpTrap(unsigned Op, EVT VT) const;
+
/// isVectorClearMaskLegal - Similar to isShuffleMaskLegal. This is
/// used by Targets can use this to indicate if there is a suitable
/// VECTOR_SHUFFLE that can be used to replace a VAND with a constant
@@ -659,12 +664,12 @@ public:
/// getOptimalMemOpType - Returns the target specific optimal type for load
/// and store operations as a result of memset, memcpy, and memmove lowering.
- /// It returns EVT::iAny if SelectionDAG should be responsible for
+ /// It returns EVT::Other if SelectionDAG should be responsible for
/// determining it.
virtual EVT getOptimalMemOpType(uint64_t Size, unsigned Align,
bool isSrcConst, bool isSrcStr,
SelectionDAG &DAG) const {
- return MVT::iAny;
+ return MVT::Other;
}
/// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
@@ -1159,7 +1164,7 @@ public:
bool isVarArg, bool isInreg, unsigned NumFixedArgs,
CallingConv::ID CallConv, bool isTailCall,
bool isReturnValueUsed, SDValue Callee, ArgListTy &Args,
- SelectionDAG &DAG, DebugLoc dl, unsigned Order);
+ SelectionDAG &DAG, DebugLoc dl);
/// LowerCall - This hook must be implemented to lower calls into the
/// the specified DAG. The outgoing arguments to the call are described
diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h
index d3e5cf2..42d88a0 100644
--- a/include/llvm/Target/TargetLoweringObjectFile.h
+++ b/include/llvm/Target/TargetLoweringObjectFile.h
@@ -25,6 +25,7 @@ namespace llvm {
class MCExpr;
class MCSection;
class MCSectionMachO;
+ class MCSymbol;
class MCContext;
class GlobalValue;
class TargetMachine;
@@ -175,187 +176,26 @@ public:
return 0;
}
- /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a
- /// pc-relative reference to the specified global variable from exception
- /// handling information. In addition to the symbol, this returns
- /// by-reference:
- ///
- /// IsIndirect - True if the returned symbol is actually a stub that contains
- /// the address of the symbol, false if the symbol is the global itself.
- ///
- /// IsPCRel - True if the symbol reference is already pc-relative, false if
- /// the caller needs to subtract off the address of the reference from the
- /// symbol.
+ /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference
+ /// to the specified global variable from exception handling information.
///
virtual const MCExpr *
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
- MachineModuleInfo *MMI,
- bool &IsIndirect, bool &IsPCRel) const;
-
-protected:
- virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-};
-
-
-
+ MachineModuleInfo *MMI, unsigned Encoding) const;
-class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
- mutable void *UniquingMap;
-protected:
- /// TLSDataSection - Section directive for Thread Local data.
- ///
- const MCSection *TLSDataSection; // Defaults to ".tdata".
-
- /// TLSBSSSection - Section directive for Thread Local uninitialized data.
- /// Null if this target doesn't support a BSS section.
- ///
- const MCSection *TLSBSSSection; // Defaults to ".tbss".
-
- const MCSection *DataRelSection;
- const MCSection *DataRelLocalSection;
- const MCSection *DataRelROSection;
- const MCSection *DataRelROLocalSection;
-
- const MCSection *MergeableConst4Section;
- const MCSection *MergeableConst8Section;
- const MCSection *MergeableConst16Section;
-
-protected:
- const MCSection *getELFSection(StringRef Section, unsigned Type,
- unsigned Flags, SectionKind Kind,
- bool IsExplicit = false) const;
-public:
- TargetLoweringObjectFileELF() : UniquingMap(0) {}
- ~TargetLoweringObjectFileELF();
-
- virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
-
- /// getSectionForConstant - Given a constant with the SectionKind, return a
- /// section that it should be placed in.
- virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
-
-
- virtual const MCSection *
- getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-
- virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-};
-
-
-
-class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
- mutable void *UniquingMap;
-
- const MCSection *CStringSection;
- const MCSection *UStringSection;
- const MCSection *TextCoalSection;
- const MCSection *ConstTextCoalSection;
- const MCSection *ConstDataCoalSection;
- const MCSection *ConstDataSection;
- const MCSection *DataCoalSection;
- const MCSection *DataCommonSection;
- const MCSection *DataBSSSection;
- const MCSection *FourByteConstantSection;
- const MCSection *EightByteConstantSection;
- const MCSection *SixteenByteConstantSection;
-
- const MCSection *LazySymbolPointerSection;
- const MCSection *NonLazySymbolPointerSection;
-public:
- TargetLoweringObjectFileMachO() : UniquingMap(0) {}
- ~TargetLoweringObjectFileMachO();
-
- virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
-
- virtual const MCSection *
- SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-
- virtual const MCSection *
- getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-
- virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
-
- /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
- /// decide not to emit the UsedDirective for some symbols in llvm.used.
- /// FIXME: REMOVE this (rdar://7071300)
- virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
- Mangler *) const;
-
- /// getMachOSection - Return the MCSection for the specified mach-o section.
- /// This requires the operands to be valid.
- const MCSectionMachO *getMachOSection(StringRef Segment,
- StringRef Section,
- unsigned TypeAndAttributes,
- SectionKind K) const {
- return getMachOSection(Segment, Section, TypeAndAttributes, 0, K);
- }
- const MCSectionMachO *getMachOSection(StringRef Segment,
- StringRef Section,
- unsigned TypeAndAttributes,
- unsigned Reserved2,
- SectionKind K) const;
-
- /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak
- /// text symbols into.
- const MCSection *getTextCoalSection() const {
- return TextCoalSection;
- }
-
- /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section
- /// we put weak read-only symbols into.
- const MCSection *getConstTextCoalSection() const {
- return ConstTextCoalSection;
- }
-
- /// getLazySymbolPointerSection - Return the section corresponding to
- /// the .lazy_symbol_pointer directive.
- const MCSection *getLazySymbolPointerSection() const {
- return LazySymbolPointerSection;
- }
-
- /// getNonLazySymbolPointerSection - Return the section corresponding to
- /// the .non_lazy_symbol_pointer directive.
- const MCSection *getNonLazySymbolPointerSection() const {
- return NonLazySymbolPointerSection;
- }
-
- /// getSymbolForDwarfGlobalReference - The mach-o version of this method
- /// defaults to returning a stub reference.
virtual const MCExpr *
- getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
- MachineModuleInfo *MMI,
- bool &IsIndirect, bool &IsPCRel) const;
-};
+ getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI,
+ unsigned Encoding) const;
+ virtual unsigned getPersonalityEncoding() const;
+ virtual unsigned getLSDAEncoding() const;
+ virtual unsigned getFDEEncoding() const;
+ virtual unsigned getTTypeEncoding() const;
-
-class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
- mutable void *UniquingMap;
-public:
- TargetLoweringObjectFileCOFF() : UniquingMap(0) {}
- ~TargetLoweringObjectFileCOFF();
-
- virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
-
- virtual const MCSection *
- getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler *Mang, const TargetMachine &TM) const;
-
+protected:
virtual const MCSection *
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const;
-
- /// getCOFFSection - Return the MCSection for the specified COFF section.
- /// FIXME: Switch this to a semantic view eventually.
- const MCSection *getCOFFSection(StringRef Name, bool isDirective,
- SectionKind K) const;
};
} // end namespace llvm
diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h
index 63e28ac..a7062ac 100644
--- a/include/llvm/Target/TargetMachine.h
+++ b/include/llvm/Target/TargetMachine.h
@@ -68,15 +68,6 @@ namespace CodeGenOpt {
};
}
-// Specify if we should encode the LSDA pointer in the FDE as 4- or 8-bytes.
-namespace DwarfLSDAEncoding {
- enum Encoding {
- Default,
- FourByte,
- EightByte
- };
-}
-
//===----------------------------------------------------------------------===//
///
/// TargetMachine - Primary interface to the complete machine description for
@@ -179,20 +170,6 @@ public:
/// is false.
static void setAsmVerbosityDefault(bool);
- /// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are
- /// 4-byte, 8-byte, and target default. The CIE is hard-coded to indicate that
- /// the LSDA pointer in the FDE section is an "sdata4", and should be encoded
- /// as a 4-byte pointer by default. However, some systems may require a
- /// different size due to bugs or other conditions. We will default to a
- /// 4-byte encoding unless the system tells us otherwise.
- ///
- /// FIXME: This call-back isn't good! We should be using the correct encoding
- /// regardless of the system. However, there are some systems which have bugs
- /// that prevent this from occuring.
- virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const {
- return DwarfLSDAEncoding::Default;
- }
-
/// CodeGenFileType - These enums are meant to be passed into
/// addPassesToEmitFile to indicate what type of file to emit, and returned by
/// it to indicate what type of file could actually be made.
@@ -212,8 +189,9 @@ public:
/// is not supported, or false on success.
virtual bool addPassesToEmitFile(PassManagerBase &,
formatted_raw_ostream &,
- CodeGenFileType Filetype,
- CodeGenOpt::Level) {
+ CodeGenFileType,
+ CodeGenOpt::Level,
+ bool DisableVerify = true) {
return true;
}
@@ -225,7 +203,8 @@ public:
///
virtual bool addPassesToEmitMachineCode(PassManagerBase &,
JITCodeEmitter &,
- CodeGenOpt::Level) {
+ CodeGenOpt::Level,
+ bool DisableVerify = true) {
return true;
}
@@ -235,7 +214,8 @@ public:
virtual bool WantsWholeFile() const { return false; }
virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &,
CodeGenFileType,
- CodeGenOpt::Level) {
+ CodeGenOpt::Level,
+ bool DisableVerify = true) {
return true;
}
};
@@ -250,7 +230,8 @@ protected: // Can only create subclasses.
/// addCommonCodeGenPasses - Add standard LLVM codegen passes used for
/// both emitting to assembly files or machine code output.
///
- bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level);
+ bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level,
+ bool DisableVerify);
private:
virtual void setCodeModelForJIT();
@@ -265,7 +246,8 @@ public:
virtual bool addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &Out,
CodeGenFileType FileType,
- CodeGenOpt::Level);
+ CodeGenOpt::Level,
+ bool DisableVerify = true);
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
/// get machine code emitted. This uses a JITCodeEmitter object to handle
@@ -275,7 +257,8 @@ public:
///
virtual bool addPassesToEmitMachineCode(PassManagerBase &PM,
JITCodeEmitter &MCE,
- CodeGenOpt::Level);
+ CodeGenOpt::Level,
+ bool DisableVerify = true);
/// Target-Independent Code Generator Pass Configuration Options.
diff --git a/include/llvm/Target/TargetOpcodes.h b/include/llvm/Target/TargetOpcodes.h
index 10cb45f..48665b7 100644
--- a/include/llvm/Target/TargetOpcodes.h
+++ b/include/llvm/Target/TargetOpcodes.h
@@ -16,7 +16,7 @@
namespace llvm {
-// Invariant opcodes: All instruction sets have these as their low opcodes.
+/// Invariant opcodes: All instruction sets have these as their low opcodes.
namespace TargetOpcode {
enum {
PHI = 0,
@@ -63,7 +63,7 @@ namespace TargetOpcode {
/// the copy are emitted with the TargetInstrInfo::copyRegToReg hook.
COPY_TO_REGCLASS = 10,
- // DBG_VALUE - a mapping of the llvm.dbg.value intrinsic
+ /// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic
DBG_VALUE = 11
};
} // end namespace TargetOpcode
diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h
index 65b60f7..212cc93 100644
--- a/include/llvm/Target/TargetRegisterInfo.h
+++ b/include/llvm/Target/TargetRegisterInfo.h
@@ -587,6 +587,17 @@ public:
return !hasFP(MF);
}
+ /// canSimplifyCallFramePseudos - When possible, it's best to simplify the
+ /// call frame pseudo ops before doing frame index elimination. This is
+ /// possible only when frame index references between the pseudos won't
+ /// need adjusted for the call frame adjustments. Normally, that's true
+ /// if the function has a reserved call frame or a frame pointer. Some
+ /// targets (Thumb2, for example) may have more complicated criteria,
+ /// however, and can override this behavior.
+ virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const {
+ return hasReservedCallFrame(MF) || hasFP(MF);
+ }
+
/// hasReservedSpillSlot - Return true if target has reserved a spill slot in
/// the stack frame of the given function for the specified register. e.g. On
/// x86, if the frame register is required, the first fixed stack object is
diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h
index 1738997..a409b62 100644
--- a/include/llvm/Target/TargetRegistry.h
+++ b/include/llvm/Target/TargetRegistry.h
@@ -26,6 +26,7 @@
namespace llvm {
class AsmPrinter;
class Module;
+ class MCAssembler;
class MCAsmInfo;
class MCAsmParser;
class MCCodeEmitter;
@@ -33,6 +34,7 @@ namespace llvm {
class MCDisassembler;
class MCInstPrinter;
class MCStreamer;
+ class TargetAsmBackend;
class TargetAsmLexer;
class TargetAsmParser;
class TargetMachine;
@@ -63,6 +65,8 @@ namespace llvm {
MCContext &Ctx,
MCStreamer &Streamer,
const MCAsmInfo *MAI);
+ typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T,
+ MCAssembler &A);
typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
const MCAsmInfo &MAI);
typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P);
@@ -72,7 +76,8 @@ namespace llvm {
const MCAsmInfo &MAI,
raw_ostream &O);
typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,
- TargetMachine &TM);
+ TargetMachine &TM,
+ MCContext &Ctx);
private:
/// Next - The next registered target in the linked list, maintained by the
@@ -93,32 +98,35 @@ namespace llvm {
bool HasJIT;
AsmInfoCtorFnTy AsmInfoCtorFn;
-
+
/// TargetMachineCtorFn - Construction function for this target's
/// TargetMachine, if registered.
TargetMachineCtorTy TargetMachineCtorFn;
- /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
- /// if registered.
- AsmPrinterCtorTy AsmPrinterCtorFn;
+ /// AsmBackendCtorFn - Construction function for this target's
+ /// TargetAsmBackend, if registered.
+ AsmBackendCtorTy AsmBackendCtorFn;
/// AsmLexerCtorFn - Construction function for this target's TargetAsmLexer,
/// if registered.
AsmLexerCtorTy AsmLexerCtorFn;
-
+
/// AsmParserCtorFn - Construction function for this target's
/// TargetAsmParser, if registered.
AsmParserCtorTy AsmParserCtorFn;
-
+
+ /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
+ /// if registered.
+ AsmPrinterCtorTy AsmPrinterCtorFn;
+
/// MCDisassemblerCtorFn - Construction function for this target's
/// MCDisassembler, if registered.
MCDisassemblerCtorTy MCDisassemblerCtorFn;
-
- /// MCInstPrinterCtorFn - Construction function for this target's
+ /// MCInstPrinterCtorFn - Construction function for this target's
/// MCInstPrinter, if registered.
MCInstPrinterCtorTy MCInstPrinterCtorFn;
-
+
/// CodeEmitterCtorFn - Construction function for this target's CodeEmitter,
/// if registered.
CodeEmitterCtorTy CodeEmitterCtorFn;
@@ -146,12 +154,18 @@ namespace llvm {
/// hasTargetMachine - Check if this target supports code generation.
bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
- /// hasAsmPrinter - Check if this target supports .s printing.
- bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; }
+ /// hasAsmBackend - Check if this target supports .o generation.
+ bool hasAsmBackend() const { return AsmBackendCtorFn != 0; }
+
+ /// hasAsmLexer - Check if this target supports .s lexing.
+ bool hasAsmLexer() const { return AsmLexerCtorFn != 0; }
/// hasAsmParser - Check if this target supports .s parsing.
bool hasAsmParser() const { return AsmParserCtorFn != 0; }
-
+
+ /// hasAsmPrinter - Check if this target supports .s printing.
+ bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; }
+
/// hasMCDisassembler - Check if this target has a disassembler.
bool hasMCDisassembler() const { return MCDisassemblerCtorFn != 0; }
@@ -164,7 +178,7 @@ namespace llvm {
/// @}
/// @name Feature Constructors
/// @{
-
+
/// createAsmInfo - Create a MCAsmInfo implementation for the specified
/// target triple.
///
@@ -177,7 +191,7 @@ namespace llvm {
return 0;
return AsmInfoCtorFn(*this, Triple);
}
-
+
/// createTargetMachine - Create a target specific machine implementation
/// for the specified \arg Triple.
///
@@ -192,14 +206,13 @@ namespace llvm {
return TargetMachineCtorFn(*this, Triple, Features);
}
- /// createAsmPrinter - Create a target specific assembly printer pass. This
- /// takes ownership of the MCContext and MCStreamer objects but not the MAI.
- AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM,
- MCContext &Ctx, MCStreamer &Streamer,
- const MCAsmInfo *MAI) const {
- if (!AsmPrinterCtorFn)
+ /// createAsmBackend - Create a target specific assembly parser.
+ ///
+ /// \arg Backend - The target independent assembler object.
+ TargetAsmBackend *createAsmBackend(MCAssembler &Backend) const {
+ if (!AsmBackendCtorFn)
return 0;
- return AsmPrinterCtorFn(OS, TM, Ctx, Streamer, MAI);
+ return AsmBackendCtorFn(*this, Backend);
}
/// createAsmLexer - Create a target specific assembly lexer.
@@ -209,7 +222,7 @@ namespace llvm {
return 0;
return AsmLexerCtorFn(*this, MAI);
}
-
+
/// createAsmParser - Create a target specific assembly parser.
///
/// \arg Parser - The target independent parser implementation to use for
@@ -219,7 +232,17 @@ namespace llvm {
return 0;
return AsmParserCtorFn(*this, Parser);
}
-
+
+ /// createAsmPrinter - Create a target specific assembly printer pass. This
+ /// takes ownership of the MCContext and MCStreamer objects but not the MAI.
+ AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM,
+ MCContext &Ctx, MCStreamer &Streamer,
+ const MCAsmInfo *MAI) const {
+ if (!AsmPrinterCtorFn)
+ return 0;
+ return AsmPrinterCtorFn(OS, TM, Ctx, Streamer, MAI);
+ }
+
const MCDisassembler *createMCDisassembler() const {
if (!MCDisassemblerCtorFn)
return 0;
@@ -233,13 +256,13 @@ namespace llvm {
return 0;
return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, O);
}
-
-
+
+
/// createCodeEmitter - Create a target specific code emitter.
- MCCodeEmitter *createCodeEmitter(TargetMachine &TM) const {
+ MCCodeEmitter *createCodeEmitter(TargetMachine &TM, MCContext &Ctx) const {
if (!CodeEmitterCtorFn)
return 0;
- return CodeEmitterCtorFn(*this, TM);
+ return CodeEmitterCtorFn(*this, TM, Ctx);
}
/// @}
@@ -269,8 +292,8 @@ namespace llvm {
return *this;
}
iterator operator++(int) { // Postincrement
- iterator tmp = *this;
- ++*this;
+ iterator tmp = *this;
+ ++*this;
return tmp;
}
@@ -312,7 +335,7 @@ namespace llvm {
/// RegisterTarget - Register the given target. Attempts to register a
/// target which has already been registered will be ignored.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
@@ -320,7 +343,7 @@ namespace llvm {
/// @param T - The target being registered.
/// @param Name - The target name. This should be a static string.
/// @param ShortDesc - A short target description. This should be a static
- /// string.
+ /// string.
/// @param TQualityFn - The triple match quality computation function for
/// this target.
/// @param HasJIT - Whether the target supports JIT code
@@ -333,11 +356,11 @@ namespace llvm {
/// RegisterAsmInfo - Register a MCAsmInfo implementation for the
/// given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
- ///
+ ///
/// @param T - The target being registered.
/// @param Fn - A function to construct a MCAsmInfo for the target.
static void RegisterAsmInfo(Target &T, Target::AsmInfoCtorFnTy Fn) {
@@ -345,76 +368,90 @@ namespace llvm {
if (!T.AsmInfoCtorFn)
T.AsmInfoCtorFn = Fn;
}
-
+
/// RegisterTargetMachine - Register a TargetMachine implementation for the
/// given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
- ///
+ ///
/// @param T - The target being registered.
/// @param Fn - A function to construct a TargetMachine for the target.
- static void RegisterTargetMachine(Target &T,
+ static void RegisterTargetMachine(Target &T,
Target::TargetMachineCtorTy Fn) {
// Ignore duplicate registration.
if (!T.TargetMachineCtorFn)
T.TargetMachineCtorFn = Fn;
}
- /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
- /// target.
- ///
+ /// RegisterAsmBackend - Register a TargetAsmBackend implementation for the
+ /// given target.
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
///
/// @param T - The target being registered.
- /// @param Fn - A function to construct an AsmPrinter for the target.
- static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
- // Ignore duplicate registration.
- if (!T.AsmPrinterCtorFn)
- T.AsmPrinterCtorFn = Fn;
+ /// @param Fn - A function to construct an AsmBackend for the target.
+ static void RegisterAsmBackend(Target &T, Target::AsmBackendCtorTy Fn) {
+ if (!T.AsmBackendCtorFn)
+ T.AsmBackendCtorFn = Fn;
}
/// RegisterAsmLexer - Register a TargetAsmLexer implementation for the
/// given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
///
/// @param T - The target being registered.
- /// @param Fn - A function to construct an AsmPrinter for the target.
+ /// @param Fn - A function to construct an AsmLexer for the target.
static void RegisterAsmLexer(Target &T, Target::AsmLexerCtorTy Fn) {
if (!T.AsmLexerCtorFn)
T.AsmLexerCtorFn = Fn;
}
-
+
/// RegisterAsmParser - Register a TargetAsmParser implementation for the
/// given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
///
/// @param T - The target being registered.
- /// @param Fn - A function to construct an AsmPrinter for the target.
+ /// @param Fn - A function to construct an AsmParser for the target.
static void RegisterAsmParser(Target &T, Target::AsmParserCtorTy Fn) {
if (!T.AsmParserCtorFn)
T.AsmParserCtorFn = Fn;
}
-
+
+ /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
+ /// target.
+ ///
+ /// Clients are responsible for ensuring that registration doesn't occur
+ /// while another thread is attempting to access the registry. Typically
+ /// this is done by initializing all targets at program startup.
+ ///
+ /// @param T - The target being registered.
+ /// @param Fn - A function to construct an AsmPrinter for the target.
+ static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
+ // Ignore duplicate registration.
+ if (!T.AsmPrinterCtorFn)
+ T.AsmPrinterCtorFn = Fn;
+ }
+
/// RegisterMCDisassembler - Register a MCDisassembler implementation for
/// the given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
///
/// @param T - The target being registered.
/// @param Fn - A function to construct an MCDisassembler for the target.
- static void RegisterMCDisassembler(Target &T,
+ static void RegisterMCDisassembler(Target &T,
Target::MCDisassemblerCtorTy Fn) {
if (!T.MCDisassemblerCtorFn)
T.MCDisassemblerCtorFn = Fn;
@@ -422,7 +459,7 @@ namespace llvm {
/// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
/// given target.
- ///
+ ///
/// Clients are responsible for ensuring that registration doesn't occur
/// while another thread is attempting to access the registry. Typically
/// this is done by initializing all targets at program startup.
@@ -434,7 +471,7 @@ namespace llvm {
if (!T.MCInstPrinterCtorFn)
T.MCInstPrinterCtorFn = Fn;
}
-
+
/// RegisterCodeEmitter - Register a MCCodeEmitter implementation for the
/// given target.
///
@@ -443,7 +480,7 @@ namespace llvm {
/// this is done by initializing all targets at program startup.
///
/// @param T - The target being registered.
- /// @param Fn - A function to construct an AsmPrinter for the target.
+ /// @param Fn - A function to construct an MCCodeEmitter for the target.
static void RegisterCodeEmitter(Target &T, Target::CodeEmitterCtorTy Fn) {
if (!T.CodeEmitterCtorFn)
T.CodeEmitterCtorFn = Fn;
@@ -497,7 +534,7 @@ namespace llvm {
static const MCAsmInfo *Allocator(const Target &T, StringRef TT) {
return new MCAsmInfoImpl(T, TT);
}
-
+
};
/// RegisterAsmInfoFn - Helper template for registering a target assembly info
@@ -536,25 +573,22 @@ namespace llvm {
}
};
- /// RegisterAsmPrinter - Helper template for registering a target specific
- /// assembly printer, for use in the target machine initialization
- /// function. Usage:
+ /// RegisterAsmBackend - Helper template for registering a target specific
+ /// assembler backend. Usage:
///
- /// extern "C" void LLVMInitializeFooAsmPrinter() {
+ /// extern "C" void LLVMInitializeFooAsmBackend() {
/// extern Target TheFooTarget;
- /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
+ /// RegisterAsmBackend<FooAsmLexer> X(TheFooTarget);
/// }
- template<class AsmPrinterImpl>
- struct RegisterAsmPrinter {
- RegisterAsmPrinter(Target &T) {
- TargetRegistry::RegisterAsmPrinter(T, &Allocator);
+ template<class AsmBackendImpl>
+ struct RegisterAsmBackend {
+ RegisterAsmBackend(Target &T) {
+ TargetRegistry::RegisterAsmBackend(T, &Allocator);
}
private:
- static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM,
- MCContext &Ctx, MCStreamer &Streamer,
- const MCAsmInfo *MAI) {
- return new AsmPrinterImpl(OS, TM, Ctx, Streamer, MAI);
+ static TargetAsmBackend *Allocator(const Target &T, MCAssembler &Backend) {
+ return new AsmBackendImpl(T, Backend);
}
};
@@ -571,7 +605,7 @@ namespace llvm {
RegisterAsmLexer(Target &T) {
TargetRegistry::RegisterAsmLexer(T, &Allocator);
}
-
+
private:
static TargetAsmLexer *Allocator(const Target &T, const MCAsmInfo &MAI) {
return new AsmLexerImpl(T, MAI);
@@ -598,6 +632,28 @@ namespace llvm {
}
};
+ /// RegisterAsmPrinter - Helper template for registering a target specific
+ /// assembly printer, for use in the target machine initialization
+ /// function. Usage:
+ ///
+ /// extern "C" void LLVMInitializeFooAsmPrinter() {
+ /// extern Target TheFooTarget;
+ /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
+ /// }
+ template<class AsmPrinterImpl>
+ struct RegisterAsmPrinter {
+ RegisterAsmPrinter(Target &T) {
+ TargetRegistry::RegisterAsmPrinter(T, &Allocator);
+ }
+
+ private:
+ static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM,
+ MCContext &Ctx, MCStreamer &Streamer,
+ const MCAsmInfo *MAI) {
+ return new AsmPrinterImpl(OS, TM, Ctx, Streamer, MAI);
+ }
+ };
+
/// RegisterCodeEmitter - Helper template for registering a target specific
/// machine code emitter, for use in the target initialization
/// function. Usage:
@@ -613,8 +669,9 @@ namespace llvm {
}
private:
- static MCCodeEmitter *Allocator(const Target &T, TargetMachine &TM) {
- return new CodeEmitterImpl(T, TM);
+ static MCCodeEmitter *Allocator(const Target &T, TargetMachine &TM,
+ MCContext &Ctx) {
+ return new CodeEmitterImpl(T, TM, Ctx);
}
};
diff --git a/include/llvm/Target/TargetSelectionDAG.td b/include/llvm/Target/TargetSelectionDAG.td
index 4b72f81..4365d33 100644
--- a/include/llvm/Target/TargetSelectionDAG.td
+++ b/include/llvm/Target/TargetSelectionDAG.td
@@ -479,7 +479,6 @@ class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;
def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>;
-def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
def immAllOnesV: PatLeaf<(build_vector), [{
return ISD::isBuildVectorAllOnes(N);
}]>;
@@ -496,7 +495,7 @@ def immAllZerosV_bc: PatLeaf<(bitconvert), [{
// Other helper fragments.
-def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
+def not : PatFrag<(ops node:$in), (xor node:$in, -1)>;
def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>;
def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>;
def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>;