Support multiple ValueTypes per RegisterClass, needed for upcoming vector
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9TmpInstr.cpp
1 //===- 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"
16 #include "llvm/Type.h"
17 #include "llvm/Support/LeakDetector.h"
18 using namespace llvm;
19
20 TmpInstruction::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 }
30
31 TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name)
32   : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
33   Ops[0].init(s1, this);  // s1 must be non-null
34   if (s2)
35     Ops[1].init(s2, this);
36
37   // TmpInstructions should not be garbage checked.
38   LeakDetector::removeGarbageObject(this);
39 }
40
41 TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
42                                Value *s1, Value *s2, const std::string &name)
43   : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) {
44   mcfi.addTemp(this);
45
46   Ops[0].init(s1, this);  // s1 must be non-null
47   if (s2)
48     Ops[1].init(s2, this);
49
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.
56 TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
57                                const Type *Ty, Value *s1, Value* s2,
58                                const std::string &name)
59   : Instruction(Ty, Instruction::UserOp1, Ops, (s1 != 0)+(s2 != 0), name) {
60   mcfi.addTemp(this);
61
62   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   }
69
70   // TmpInstructions should not be garbage checked.
71   LeakDetector::removeGarbageObject(this);
72 }