[llvm-commits] CVS: llvm/include/llvm/Target/TargetSubtarget.h TargetMachine.h

Nate Begeman natebegeman at mac.com
Mon Jul 11 18:42:06 PDT 2005



Changes in directory llvm/include/llvm/Target:

TargetSubtarget.h added (r1.1)
TargetMachine.h updated: 1.53 -> 1.54
---
Log message:

Implement Subtarget support
Implement the X86 Subtarget.

This consolidates the checks for target triple, and setting options based
on target triple into one place.  This allows us to convert the asm printer
and isel over from being littered with "forDarwin", "forCygwin", etc. into
just having the appropriate flags for each subtarget feature controlling
the code for that feature.

This patch also implements indirect external and weak references in the
X86 pattern isel, for darwin.  Next up is to convert over the asm printers
to use this new interface.


---
Diffs of the changes:  (+49 -0)

 TargetMachine.h   |    8 ++++++++
 TargetSubtarget.h |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)


Index: llvm/include/llvm/Target/TargetSubtarget.h
diff -c /dev/null llvm/include/llvm/Target/TargetSubtarget.h:1.1
*** /dev/null	Mon Jul 11 20:42:04 2005
--- llvm/include/llvm/Target/TargetSubtarget.h	Mon Jul 11 20:41:54 2005
***************
*** 0 ****
--- 1,41 ----
+ //==-- llvm/Target/TargetSubtarget.h - Target Information --------*- C++ -*-==//
+ //
+ //                     The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Nate Begeman and is distributed under the
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file describes the subtarget options of a Target machine.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #ifndef LLVM_TARGET_TARGETSUBTARGET_H
+ #define LLVM_TARGET_TARGETSUBTARGET_H
+ 
+ namespace llvm {
+ 
+ class Module;
+ 
+ //===----------------------------------------------------------------------===//
+ ///
+ /// TargetSubtarget - Generic base class for all target subtargets.  All
+ /// Target-specific options that control code generation and printing should
+ /// be exposed through a TargetSubtarget-derived class.
+ ///
+ class TargetSubtarget {
+   TargetSubtarget(const TargetSubtarget&);   // DO NOT IMPLEMENT
+   void operator=(const TargetSubtarget&);  // DO NOT IMPLEMENT
+ protected: // Can only create subclasses...
+   /// This constructor initializes the data members to match that 
+   /// of the specified module.
+   ///
+   TargetSubtarget(const Module &M);
+ public:
+   virtual ~TargetSubtarget();
+ };
+ 
+ } // End llvm namespace
+ 
+ #endif


Index: llvm/include/llvm/Target/TargetMachine.h
diff -u llvm/include/llvm/Target/TargetMachine.h:1.53 llvm/include/llvm/Target/TargetMachine.h:1.54
--- llvm/include/llvm/Target/TargetMachine.h:1.53	Fri Jun 24 22:31:43 2005
+++ llvm/include/llvm/Target/TargetMachine.h	Mon Jul 11 20:41:54 2005
@@ -19,6 +19,7 @@
 
 namespace llvm {
 
+class TargetSubtarget;
 class TargetInstrInfo;
 class TargetInstrDescriptor;
 class TargetJITInfo;
@@ -97,6 +98,13 @@
   virtual const TargetFrameInfo        *getFrameInfo() const { return 0; }
   const TargetData &getTargetData() const { return DataLayout; }
 
+  virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
+  template<typename STC> STC *getSubtarget() const {
+    assert(getSubtargetImpl() && dynamic_cast<STC*>(getSubtargetImpl()) &&
+           "Not the right kind of subtarget!");
+    return (STC*)getSubtargetImpl();
+  }
+
   /// getRegisterInfo - If register information is available, return it.  If
   /// not, return null.  This is kept separate from RegInfo until RegInfo has
   /// details of graph coloring register allocation removed from it.






More information about the llvm-commits mailing list