blob: 5b954b426bd57aaa2626505eab75cb06676e2465 [file] [log] [blame]
Brian Gaekeb3e3c532004-08-04 07:29:04 +00001//===- SparcV9TmpInstr.cpp - SparcV9 Intermediate Value class -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Methods of class for temporary intermediate values used within the current
11// SparcV9 backend.
12//
13//===----------------------------------------------------------------------===//
14
15#include "SparcV9TmpInstr.h"
Chris Lattner7b9020a2005-03-17 15:38:16 +000016#include "llvm/Type.h"
Reid Spencer7c16caa2004-09-01 22:55:40 +000017#include "llvm/Support/LeakDetector.h"
Chris Lattner3479f9c2005-01-29 00:36:59 +000018using namespace llvm;
Brian Gaekeb3e3c532004-08-04 07:29:04 +000019
Chris Lattner3479f9c2005-01-29 00:36:59 +000020TmpInstruction::TmpInstruction(const TmpInstruction &TI)
21 : Instruction(TI.getType(), TI.getOpcode(), Ops, TI.getNumOperands()) {
22 if (TI.getNumOperands()) {
23 Ops[0].init(TI.Ops[0], this);
24 if (TI.getNumOperands() == 2)
25 Ops[1].init(TI.Ops[1], this);
26 else
27 assert(0 && "Bad # operands to TmpInstruction!");
28 }
29}
Brian Gaekeb3e3c532004-08-04 07:29:04 +000030
31TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name)
Chris Lattner3479f9c2005-01-29 00:36:59 +000032 : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
33 Ops[0].init(s1, this); // s1 must be non-null
Brian Gaekeb3e3c532004-08-04 07:29:04 +000034 if (s2)
Chris Lattner3479f9c2005-01-29 00:36:59 +000035 Ops[1].init(s2, this);
Brian Gaekeb3e3c532004-08-04 07:29:04 +000036
37 // TmpInstructions should not be garbage checked.
38 LeakDetector::removeGarbageObject(this);
39}
40
41TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
42 Value *s1, Value *s2, const std::string &name)
Chris Lattner3479f9c2005-01-29 00:36:59 +000043 : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
Brian Gaekeb3e3c532004-08-04 07:29:04 +000044 mcfi.addTemp(this);
45
Chris Lattner3479f9c2005-01-29 00:36:59 +000046 Ops[0].init(s1, this); // s1 must be non-null
Brian Gaekeb3e3c532004-08-04 07:29:04 +000047 if (s2)
Chris Lattner3479f9c2005-01-29 00:36:59 +000048 Ops[1].init(s2, this);
Brian Gaekeb3e3c532004-08-04 07:29:04 +000049
50 // TmpInstructions should not be garbage checked.
51 LeakDetector::removeGarbageObject(this);
52}
53
54// Constructor that requires the type of the temporary to be specified.
55// Both S1 and S2 may be NULL.
56TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
57 const Type *Ty, Value *s1, Value* s2,
58 const std::string &name)
Chris Lattner3479f9c2005-01-29 00:36:59 +000059 : Instruction(Ty, Instruction::UserOp1, Ops, (s1 != 0)+(s2 != 0), name) {
Brian Gaekeb3e3c532004-08-04 07:29:04 +000060 mcfi.addTemp(this);
61
Chris Lattner3479f9c2005-01-29 00:36:59 +000062 assert((s1 != 0 || s2 == 0) &&
63 "s2 cannot be non-null if s1 is non-null!");
64 if (s1) {
65 Ops[0].init(s1, this);
66 if (s2)
67 Ops[1].init(s2, this);
68 }
Brian Gaekeb3e3c532004-08-04 07:29:04 +000069
70 // TmpInstructions should not be garbage checked.
71 LeakDetector::removeGarbageObject(this);
72}