OpenASIP  2.0
LLVMPOMBuilder.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 LLVMPOMBuilder.hh
26  *
27  * Declaration of LLVMPOMBuilder class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2007 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2007-2010
31  * @note reting: red
32  */
33 
34 #ifndef LLVM_POM_BUILDER_H
35 #define LLVM_POM_BUILDER_H
36 
37 #include "CompilerWarnings.hh"
38 
39 IGNORE_COMPILER_WARNING("-Wunused-parameter")
40 
41 #include "LLVMTCEBuilder.hh"
42 #include "TCETargetMachine.hh"
43 
45 
46 namespace TTAMachine {
47  class Machine;
48 }
49 
50 namespace llvm {
51 
52  FunctionPass* createLLVMPOMBuilderPass(
53  TCETargetMachine& tm, TTAMachine::Machine* mach);
54 
55  /**
56  * Implements building unscheduled TCE POM from RISC-style sequential input
57  * from LLVM codegen.
58  *
59  * The resulting POM has the registers allocated but
60  * the FUs and the buses unassigned.
61  */
62  class LLVMPOMBuilder : public LLVMTCEBuilder {
63  public:
64  static char ID; // Pass identification, replacement for typeid
65 
66  LLVMPOMBuilder(char& ID);
67 
68  bool doFinalization(Module& m);
69 
71  TCETargetMachine& tm,
72  TTAMachine::Machine* mach);
73 
74  virtual ~LLVMPOMBuilder() {}
75 
76  protected:
77 
78  virtual unsigned spDRegNum() const {
79  return dynamic_cast<const TCETargetMachine&>(
81  }
82 
83  // the return address register's llvm reg number
84  virtual unsigned raPortDRegNum() const {
85  return dynamic_cast<const TCETargetMachine&>(
87  }
88 
89  // the ADF register file name of the llvm reg number
90  virtual TCEString registerFileName(unsigned llvmRegNum) const {
91  return dynamic_cast<const TCETargetMachine&>(
92  targetMachine()).rfName(llvmRegNum);
93  }
94 
95  // the ADF register index of the llvm reg number
96  virtual int registerIndex(unsigned llvmRegNum) const {
97  return dynamic_cast<const TCETargetMachine&>(
98  targetMachine()).registerIndex(llvmRegNum);
99  }
100 
101  // OSAL operation name from a LLVM MachineInstr
102  virtual TCEString operationName(const MachineInstr& mi) const {
103  return dynamic_cast<const TCETargetMachine&>(
104  targetMachine()).operationName(mi.getDesc().getOpcode());
105  }
106 
108  const MachineOperand&) const {
109  // no FU terminals in the RISC-style backend, always through GPRs
110  return NULL;
111  }
112  };
113 }
114 #endif
llvm
Definition: InlineAsmParser.hh:49
llvm::LLVMPOMBuilder::createFUTerminal
virtual TTAProgram::Terminal * createFUTerminal(const MachineOperand &) const
Definition: LLVMPOMBuilder.hh:107
llvm::LLVMPOMBuilder::doFinalization
bool doFinalization(Module &m)
Definition: LLVMPOMBuilder.cc:49
llvm::LLVMPOMBuilder::~LLVMPOMBuilder
virtual ~LLVMPOMBuilder()
Definition: LLVMPOMBuilder.hh:74
llvm::LLVMPOMBuilder
Definition: LLVMPOMBuilder.hh:62
TCETargetMachine.hh
llvm::LLVMPOMBuilder::spDRegNum
virtual unsigned spDRegNum() const
Definition: LLVMPOMBuilder.hh:78
llvm::LLVMPOMBuilder::raPortDRegNum
virtual unsigned raPortDRegNum() const
Definition: LLVMPOMBuilder.hh:84
llvm::LLVMPOMBuilder::registerFileName
virtual TCEString registerFileName(unsigned llvmRegNum) const
Definition: LLVMPOMBuilder.hh:90
llvm::LLVMPOMBuilder::LLVMPOMBuilder
LLVMPOMBuilder(char &ID)
Definition: LLVMPOMBuilder.cc:45
IGNORE_COMPILER_WARNING
#define IGNORE_COMPILER_WARNING(X)
Definition: CompilerWarnings.hh:51
llvm::LLVMPOMBuilder::operationName
virtual TCEString operationName(const MachineInstr &mi) const
Definition: LLVMPOMBuilder.hh:102
llvm::createLLVMPOMBuilderPass
FunctionPass * createLLVMPOMBuilderPass(TCETargetMachine &tm, TTAMachine::Machine *mach)
Definition: LLVMPOMBuilder.cc:56
llvm::LLVMPOMBuilder::registerIndex
virtual int registerIndex(unsigned llvmRegNum) const
Definition: LLVMPOMBuilder.hh:96
TCEString
Definition: TCEString.hh:53
llvm::LLVMPOMBuilder::ID
static char ID
Definition: LLVMPOMBuilder.hh:64
POP_COMPILER_DIAGS
#define POP_COMPILER_DIAGS
Definition: CompilerWarnings.hh:68
llvm::TCETargetMachine
Definition: TCETargetMachine.hh:106
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAMachine
Definition: Assembler.hh:48
llvm::LLVMTCEBuilder
Definition: LLVMTCEBuilder.hh:102
llvm::LLVMTCEBuilder::targetMachine
const TargetMachine & targetMachine() const
Definition: LLVMTCEBuilder.hh:157
CompilerWarnings.hh
TTAMachine::Machine
Definition: Machine.hh:73