diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Target/TargetMachine.h | 8 | ||||
-rw-r--r-- | include/llvm/Target/TargetSubtarget.h | 41 |
2 files changed, 49 insertions, 0 deletions
diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 6e3fe35..efeb61d 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -19,6 +19,7 @@ namespace llvm { +class TargetSubtarget; class TargetInstrInfo; class TargetInstrDescriptor; class TargetJITInfo; @@ -97,6 +98,13 @@ public: 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. diff --git a/include/llvm/Target/TargetSubtarget.h b/include/llvm/Target/TargetSubtarget.h new file mode 100644 index 0000000..e99afe2 --- /dev/null +++ b/include/llvm/Target/TargetSubtarget.h @@ -0,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 |