OpenASIP  2.0
TCEStubTargetMachine.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2015 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 /**
25  * @file TCEStubTargetMachine.hh
26  *
27  * Declaration of TCEStubTargetMachine class.
28  *
29  * @author Ville Korhonen 2015
30  */
31 
32 #ifndef TTA_TCE_STUB_TARGET_MACHINE_HH
33 #define TTA_TCE_STUB_TARGET_MACHINE_HH
34 
35 #include "tce_config.h"
36 
37 #include "llvm/MC/TargetRegistry.h"
38 #include <llvm/Target/TargetMachine.h>
39 #include <llvm/CodeGen/TargetLowering.h>
40 // LLVM has function with parameter named as "PIC". Command line
41 // option -DPIC messes up the compilation.
42 #define PICCOPY PIC
43 #undef PIC
44 #include <llvm/Target/TargetLoweringObjectFile.h>
45 #include <llvm/CodeGen/TargetLoweringObjectFileImpl.h>
46 #define PIC PICCOPY
47 #undef PICCOPY
48 
49 // TODO: What was the meaning of this. may have been broken with a merge.
50 //#ifndef PACKAGE
51 //#include "tce_config.h"
52 //#endif
53 
54 #include "TCEStubSubTarget.hh"
55 
56 // initializes TCE target to LLVM
57 extern "C" void LLVMInitializeTCETargetInfo();
58 
59 // initializes TCEStub as the targetmachine impl. for the TCE Target
60 extern "C" void LLVMInitializeTCEStubTarget();
61 
62 namespace TTAMachine {
63  class Machine;
64 }
65 
66 namespace llvm {
67  extern Target TheTCETarget;
68  extern Target TheTCELETarget;
69  extern Target TheTCELE64Target;
70 
71  class MCContext;
72  class TargetMachine;
73  class StringRef;
74  class TCEStubTargetMachine;
75  class TCEStubSubTarget;
76  class TargetSubTargetInfo;
77 
78  /**
79  * Base class common to TCEStubTargetMachine(for middle end) and
80  * TCETargetMachine(for backend)
81  */
82  class TCEBaseTargetMachine : public LLVMTargetMachine {
83  public:
85  const Target& T, const Triple& TT, const llvm::StringRef& CPU,
86  const llvm::StringRef& FS, const TargetOptions& Options,
87  Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL);
88  virtual bool
89  isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
90  return true;
91  }
93  virtual void
95  ttaMach_ = mach;
96  }
97  };
98 
99  /**
100  * TargetStub for middle end optimizations. (for loopvectorizer initially)
101  */
103  protected:
104  std::unique_ptr<TargetLoweringObjectFile> TLOF;
106 
107  public:
109  const Target &T, const Triple& TT,
110  const llvm::StringRef& CPU, const llvm::StringRef& FS,
111  const TargetOptions &Options,
112  Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
113  CodeGenOpt::Level OL, bool isLittle);
114 
115  // TODO: this is no longer virtual in llvm 6.0
116  // I wonder what this button does..
117  virtual ~TCEStubTargetMachine();
118 
119  //const TargetSubtargetInfo *getSubtargetImpl() const {
121  return ST;
122  }
123  const TCEStubSubTarget *getSubtargetImpl(const Function&)
124  const override {
125  return ST;
126  }
127 
128  static void setADFString(std::string adfXML);
129 
130  static std::string adfXML_;
131  };
132 } //end namespace llvm
133 #endif
llvm
Definition: InlineAsmParser.hh:49
llvm::TCEStubTargetMachine
Definition: TCEStubTargetMachine.hh:102
Options
Definition: Options.hh:51
llvm::TheTCETarget
Target TheTCETarget
Definition: TCEStubTargetMachine.cc:63
llvm::TheTCELETarget
Target TheTCELETarget
Definition: TCEStubTargetMachine.cc:64
llvm::TCEStubTargetMachine::setADFString
static void setADFString(std::string adfXML)
Definition: TCEStubTargetMachine.cc:160
llvm::TCEBaseTargetMachine::setTTAMach
virtual void setTTAMach(const TTAMachine::Machine *mach)
Definition: TCEStubTargetMachine.hh:94
llvm::TCEStubTargetMachine::adfXML_
static std::string adfXML_
Definition: TCEStubTargetMachine.hh:130
llvm::TCEStubTargetMachine::getSubtargetImpl
const TCEStubSubTarget * getSubtargetImpl(const Function &) const override
Definition: TCEStubTargetMachine.hh:123
llvm::TCEBaseTargetMachine::TCEBaseTargetMachine
TCEBaseTargetMachine(const Target &T, const Triple &TT, const llvm::StringRef &CPU, const llvm::StringRef &FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Definition: TCEStubTargetMachine.cc:125
llvm::TCEStubTargetMachine::TCEStubTargetMachine
TCEStubTargetMachine(const Target &T, const Triple &TT, const llvm::StringRef &CPU, const llvm::StringRef &FS, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool isLittle)
Definition: TCEStubTargetMachine.cc:134
LLVMInitializeTCETargetInfo
void LLVMInitializeTCETargetInfo()
Definition: TCEStubTargetMachine.cc:67
llvm::TCEStubTargetMachine::getSubtargetImpl
const TCEStubSubTarget * getSubtargetImpl() const
Definition: TCEStubTargetMachine.hh:120
llvm::TCEStubSubTarget
Definition: TCEStubSubTarget.hh:51
llvm::TCEBaseTargetMachine
Definition: TCEStubTargetMachine.hh:82
llvm::TCEBaseTargetMachine::ttaMach_
const TTAMachine::Machine * ttaMach_
Definition: TCEStubTargetMachine.hh:92
llvm::TCEStubTargetMachine::ST
TCEStubSubTarget * ST
Definition: TCEStubTargetMachine.hh:105
TCEStubSubTarget.hh
LLVMInitializeTCEStubTarget
void LLVMInitializeTCEStubTarget()
Definition: TCEStubTargetMachine.cc:80
TTAMachine
Definition: Assembler.hh:48
llvm::TheTCELE64Target
Target TheTCELE64Target
Definition: TCEStubTargetMachine.cc:65
llvm::TCEBaseTargetMachine::isNoopAddrSpaceCast
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Definition: TCEStubTargetMachine.hh:89
TTAMachine::Machine
Definition: Machine.hh:73
llvm::TCEStubTargetMachine::TLOF
std::unique_ptr< TargetLoweringObjectFile > TLOF
Definition: TCEStubTargetMachine.hh:104
llvm::TCEStubTargetMachine::~TCEStubTargetMachine
virtual ~TCEStubTargetMachine()
Definition: TCEStubTargetMachine.cc:157