OpenASIP 2.2
Loading...
Searching...
No Matches
Macros | Functions
ConstantTransformer.cc File Reference
#include "CompilerWarnings.hh"
#include "ConstantTransformer.hh"
#include "MachineInfo.hh"
#include "TCETargetMachine.hh"
#include "OperationPool.hh"
#include "Operation.hh"
#include "Operand.hh"
#include <llvm/CodeGen/MachineFunction.h>
#include <llvm/CodeGen/MachineBasicBlock.h>
#include <llvm/MC/MCInstrInfo.h>
#include <llvm/CodeGen/TargetInstrInfo.h>
#include <llvm/CodeGen/TargetSubtargetInfo.h>
#include <llvm/CodeGen/TargetOpcodes.h>
#include <llvm/CodeGen/MachineInstrBuilder.h>
#include <sstream>
Include dependency graph for ConstantTransformer.cc:

Go to the source code of this file.

Macros

#define sub   "SUB"
 

Functions

unsigned osalInputIndex (const Operation &operation, const llvm::MachineInstr &instr, unsigned operandId)
 

Detailed Description

Implementation of ConstantTransformer class.

Author
Pekka Jääskeläinen 2015
Note
reting: red

Definition in file ConstantTransformer.cc.

Macro Definition Documentation

◆ sub

#define sub   "SUB"

Definition at line 63 of file ConstantTransformer.cc.

Function Documentation

◆ osalInputIndex()

unsigned osalInputIndex ( const Operation operation,
const llvm::MachineInstr &  instr,
unsigned  operandId 
)

In case the given operandId is an input operand in the MachineInstr, returns the corresponding OSAL operand id (starting from 1), 0 otherwise.

Definition at line 78 of file ConstantTransformer.cc.

81 {
82
83 const TCETargetMachine& tm =
84 dynamic_cast<const TCETargetMachine&>(
85 instr.getParent()->getParent()->getTarget());
86
87 TCEString operationName = tm.operationName(instr.getDesc().getOpcode());
88 bool hasGuard = operationName[0] == '?' || operationName[0] == '!';
89
90 unsigned osalIndex = 0;
91 for (unsigned operandI = 0; operandI < instr.getNumOperands(); ++operandI) {
92 const MachineOperand& mo = instr.getOperand(operandI);
93 if (hasGuard && operandI == 0) continue;
94 // Output or metadata.
95 if ((mo.isReg() && (mo.isDef() || mo.isImplicit())) || mo.isMetadata())
96 continue;
97 ++osalIndex;
98 if (operandI == operandId) return osalIndex;
99 // LLVM machineinstructions always present the addresses in the
100 // base + offset form, thus consume two input operands per one
101 // OSAL operand. Skip the offset operand in case the OSAL operation
102 // only the takes a single absolute address.
103 if (operation.operand(osalIndex).isAddress() &&
104 !operation.isBaseOffsetMemOperation()) {
105 ++operandI;
106 }
107 }
108
109 return 0;
110}
virtual bool isAddress() const
Definition Operand.cc:328
virtual bool isBaseOffsetMemOperation() const
Definition Operation.cc:323
virtual Operand & operand(int id) const
Definition Operation.cc:541
std::string operationName(unsigned opc) const

References Operand::isAddress(), Operation::isBaseOffsetMemOperation(), Operation::operand(), and llvm::TCETargetMachine::operationName().

Referenced by ConstantTransformer::runOnMachineFunction().

Here is the call graph for this function: