[llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp SparcV9TmpInstr.h
Brian Gaeke
gaeke at cs.uiuc.edu
Wed Aug 4 00:29:15 PDT 2004
Changes in directory llvm/lib/Target/SparcV9:
SparcV9TmpInstr.cpp added (r1.1)
SparcV9TmpInstr.h added (r1.1)
---
Log message:
Add a new file containing just TmpInstruction and its implementation.
Many other pieces of the SparcV9 backend want to use TmpInstruction, but
don't need any other instruction selector baggage.
---
Diffs of the changes: (+132 -0)
Index: llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp
diff -c /dev/null llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp:1.1
*** /dev/null Wed Aug 4 02:29:14 2004
--- llvm/lib/Target/SparcV9/SparcV9TmpInstr.cpp Wed Aug 4 02:29:04 2004
***************
*** 0 ****
--- 1,60 ----
+ //===- SparcV9TmpInstr.cpp - SparcV9 Intermediate Value class -------------===//
+ //
+ // 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.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // Methods of class for temporary intermediate values used within the current
+ // SparcV9 backend.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "SparcV9TmpInstr.h"
+ #include "Support/LeakDetector.h"
+
+ namespace llvm {
+
+ TmpInstruction::TmpInstruction(Value *s1, Value *s2, const std::string &name)
+ : Instruction(s1->getType(), Instruction::UserOp1, name) {
+ Operands.push_back(Use(s1, this)); // s1 must be non-null
+ if (s2)
+ Operands.push_back(Use(s2, this));
+
+ // TmpInstructions should not be garbage checked.
+ LeakDetector::removeGarbageObject(this);
+ }
+
+ TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi,
+ Value *s1, Value *s2, const std::string &name)
+ : Instruction(s1->getType(), Instruction::UserOp1, name) {
+ mcfi.addTemp(this);
+
+ Operands.push_back(Use(s1, this)); // s1 must be non-null
+ if (s2)
+ Operands.push_back(Use(s2, this));
+
+ // 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)
+ : Instruction(Ty, Instruction::UserOp1, name) {
+ mcfi.addTemp(this);
+
+ if (s1)
+ Operands.push_back(Use(s1, this));
+ if (s2)
+ Operands.push_back(Use(s2, this));
+
+ // TmpInstructions should not be garbage checked.
+ LeakDetector::removeGarbageObject(this);
+ }
+
+ } // end namespace llvm
Index: llvm/lib/Target/SparcV9/SparcV9TmpInstr.h
diff -c /dev/null llvm/lib/Target/SparcV9/SparcV9TmpInstr.h:1.1
*** /dev/null Wed Aug 4 02:29:15 2004
--- llvm/lib/Target/SparcV9/SparcV9TmpInstr.h Wed Aug 4 02:29:04 2004
***************
*** 0 ****
--- 1,72 ----
+ //===-- SparcV9TmpInstr.h ---------------------------------------*- C++ -*-===//
+ //
+ // 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.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // Definition of class for temporary intermediate values used within the current
+ // SparcV9 backend.
+ //
+ //===----------------------------------------------------------------------===//
+
+ #ifndef SPARCV9TMPINSTR_H
+ #define SPARCV9TMPINSTR_H
+
+ #include "llvm/Instruction.h"
+ #include "llvm/CodeGen/MachineCodeForInstruction.h"
+
+ namespace llvm {
+
+ /// TmpInstruction - This class represents temporary intermediate
+ /// values used within the SparcV9 machine code for an LLVM instruction.
+ ///
+ class TmpInstruction : public Instruction {
+ TmpInstruction(const TmpInstruction &TI)
+ : Instruction(TI.getType(), TI.getOpcode()) {
+ if (!TI.Operands.empty()) {
+ Operands.push_back(Use(TI.Operands[0], this));
+ if (TI.Operands.size() == 2)
+ Operands.push_back(Use(TI.Operands[1], this));
+ else
+ assert(0 && "Bad # operands to TmpInstruction!");
+ }
+ }
+ public:
+ // Constructor that uses the type of S1 as the type of the temporary.
+ // s1 must be a valid value. s2 may be NULL.
+ TmpInstruction(MachineCodeForInstruction &mcfi,
+ Value *s1, Value *s2 = 0, const std::string &name = "");
+
+ // Constructor that uses the type of S1 as the type of the temporary,
+ // but does not require a MachineCodeForInstruction.
+ // s1 must be a valid value. s2 may be NULL.
+ TmpInstruction(Value *s1, Value *s2 = 0, const std::string &name = "");
+
+ // Constructor that requires the type of the temporary to be specified.
+ // Both S1 and S2 may be NULL.
+ TmpInstruction(MachineCodeForInstruction& mcfi,
+ const Type *Ty, Value *s1 = 0, Value* s2 = 0,
+ const std::string &name = "");
+
+ virtual Instruction *clone() const {
+ assert(0 && "Cannot clone TmpInstructions!");
+ return 0;
+ }
+ virtual const char *getOpcodeName() const { return "TmpInstruction"; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const TmpInstruction *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return (I->getOpcode() == Instruction::UserOp1);
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
+ };
+
+ } // End llvm namespace
+
+ #endif
More information about the llvm-commits
mailing list