| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 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" |
| Chris Lattner | 7b9020a | 2005-03-17 15:38:16 +0000 | [diff] [blame] | 16 | #include "llvm/Type.h" |
| Reid Spencer | 7c16caa | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 17 | #include "llvm/Support/LeakDetector.h" |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 19 | |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 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 | } |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 30 | |
| 31 | TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name) |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 32 | : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) { |
| 33 | Ops[0].init(s1, this); // s1 must be non-null |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 34 | if (s2) |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 35 | Ops[1].init(s2, this); |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 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) |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 43 | : Instruction(s1->getType(), Instruction::UserOp1, Ops, 1+(s2 != 0), name) { |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 44 | mcfi.addTemp(this); |
| 45 | |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 46 | Ops[0].init(s1, this); // s1 must be non-null |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 47 | if (s2) |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 48 | Ops[1].init(s2, this); |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 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) |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 59 | : Instruction(Ty, Instruction::UserOp1, Ops, (s1 != 0)+(s2 != 0), name) { |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 60 | mcfi.addTemp(this); |
| 61 | |
| Chris Lattner | 3479f9c | 2005-01-29 00:36:59 +0000 | [diff] [blame] | 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 | } |
| Brian Gaeke | b3e3c53 | 2004-08-04 07:29:04 +0000 | [diff] [blame] | 69 | |
| 70 | // TmpInstructions should not be garbage checked. |
| 71 | LeakDetector::removeGarbageObject(this); |
| 72 | } |