2004-08-04 07:29:04 +00:00
|
|
|
//===- SparcV9TmpInstr.cpp - SparcV9 Intermediate Value class -------------===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-04 07:29:04 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-04 07:29:04 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Methods of class for temporary intermediate values used within the current
|
|
|
|
// SparcV9 backend.
|
2005-07-27 06:12:32 +00:00
|
|
|
//
|
2004-08-04 07:29:04 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcV9TmpInstr.h"
|
2005-03-17 15:38:16 +00:00
|
|
|
#include "llvm/Type.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/LeakDetector.h"
|
2005-01-29 00:36:59 +00:00
|
|
|
using namespace llvm;
|
2004-08-04 07:29:04 +00:00
|
|
|
|
2005-01-29 00:36:59 +00:00
|
|
|
TmpInstruction::TmpInstruction(const TmpInstruction &TI)
|
|
|
|
: Instruction(TI.getType(), TI.getOpcode(), Ops, TI.getNumOperands()) {
|
|
|
|
if (TI.getNumOperands()) {
|
|
|
|
Ops[0].init(TI.Ops[0], this);
|
|
|
|
if (TI.getNumOperands() == 2)
|
|
|
|
Ops[1].init(TI.Ops[1], this);
|
|
|
|
else
|
|
|
|
assert(0 && "Bad # operands to TmpInstruction!");
|
|
|
|
}
|
|
|
|
}
|
2004-08-04 07:29:04 +00:00
|
|
|
|
|
|
|
TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name)
|
2005-01-29 00:36:59 +00:00
|
|
|
: Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
|
|
|
|
Ops[0].init(s1, this); // s1 must be non-null
|
2004-08-04 07:29:04 +00:00
|
|
|
if (s2)
|
2005-01-29 00:36:59 +00:00
|
|
|
Ops[1].init(s2, this);
|
2004-08-04 07:29:04 +00:00
|
|
|
|
|
|
|
// TmpInstructions should not be garbage checked.
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
|
|
|
|
Value *s1, Value *s2, const std::string &name)
|
2005-01-29 00:36:59 +00:00
|
|
|
: Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
|
2004-08-04 07:29:04 +00:00
|
|
|
mcfi.addTemp(this);
|
|
|
|
|
2005-01-29 00:36:59 +00:00
|
|
|
Ops[0].init(s1, this); // s1 must be non-null
|
2004-08-04 07:29:04 +00:00
|
|
|
if (s2)
|
2005-01-29 00:36:59 +00:00
|
|
|
Ops[1].init(s2, this);
|
2004-08-04 07:29:04 +00:00
|
|
|
|
|
|
|
// TmpInstructions should not be garbage checked.
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor that requires the type of the temporary to be specified.
|
|
|
|
// Both S1 and S2 may be NULL.
|
|
|
|
TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
|
|
|
|
const Type *Ty, Value *s1, Value* s2,
|
|
|
|
const std::string &name)
|
2005-01-29 00:36:59 +00:00
|
|
|
: Instruction(Ty, Instruction::UserOp1, Ops, (s1 != 0)+(s2 != 0), name) {
|
2004-08-04 07:29:04 +00:00
|
|
|
mcfi.addTemp(this);
|
|
|
|
|
2005-01-29 00:36:59 +00:00
|
|
|
assert((s1 != 0 || s2 == 0) &&
|
|
|
|
"s2 cannot be non-null if s1 is non-null!");
|
|
|
|
if (s1) {
|
|
|
|
Ops[0].init(s1, this);
|
|
|
|
if (s2)
|
|
|
|
Ops[1].init(s2, this);
|
|
|
|
}
|
2004-08-04 07:29:04 +00:00
|
|
|
|
|
|
|
// TmpInstructions should not be garbage checked.
|
|
|
|
LeakDetector::removeGarbageObject(this);
|
|
|
|
}
|