blob: fa718656623b7b802026dfaa3909a958379a1ab5 [file] [log] [blame]
Brian Gaekeb3e3c532004-08-04 07:29:04 +00001//===-- SparcV9TmpInstr.h ---------------------------------------*- C++ -*-===//
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// Definition of class for temporary intermediate values used within the current
11// SparcV9 backend.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef SPARCV9TMPINSTR_H
16#define SPARCV9TMPINSTR_H
17
18#include "llvm/Instruction.h"
Chris Lattner9fb30a42004-08-16 21:55:02 +000019#include "MachineCodeForInstruction.h"
Brian Gaekeb3e3c532004-08-04 07:29:04 +000020
21namespace llvm {
22
23/// TmpInstruction - This class represents temporary intermediate
24/// values used within the SparcV9 machine code for an LLVM instruction.
25///
26class TmpInstruction : public Instruction {
27 TmpInstruction(const TmpInstruction &TI)
28 : Instruction(TI.getType(), TI.getOpcode()) {
29 if (!TI.Operands.empty()) {
30 Operands.push_back(Use(TI.Operands[0], this));
31 if (TI.Operands.size() == 2)
32 Operands.push_back(Use(TI.Operands[1], this));
33 else
34 assert(0 && "Bad # operands to TmpInstruction!");
35 }
36 }
37public:
38 // Constructor that uses the type of S1 as the type of the temporary.
39 // s1 must be a valid value. s2 may be NULL.
40 TmpInstruction(MachineCodeForInstruction &mcfi,
41 Value *s1, Value *s2 = 0, const std::string &name = "");
42
43 // Constructor that uses the type of S1 as the type of the temporary,
44 // but does not require a MachineCodeForInstruction.
45 // s1 must be a valid value. s2 may be NULL.
46 TmpInstruction(Value *s1, Value *s2 = 0, const std::string &name = "");
47
48 // Constructor that requires the type of the temporary to be specified.
49 // Both S1 and S2 may be NULL.
50 TmpInstruction(MachineCodeForInstruction& mcfi,
51 const Type *Ty, Value *s1 = 0, Value* s2 = 0,
52 const std::string &name = "");
53
54 virtual Instruction *clone() const {
55 assert(0 && "Cannot clone TmpInstructions!");
56 return 0;
57 }
58 virtual const char *getOpcodeName() const { return "TmpInstruction"; }
59
60 // Methods for support type inquiry through isa, cast, and dyn_cast:
61 static inline bool classof(const TmpInstruction *) { return true; }
62 static inline bool classof(const Instruction *I) {
63 return (I->getOpcode() == Instruction::UserOp1);
64 }
65 static inline bool classof(const Value *V) {
66 return isa<Instruction>(V) && classof(cast<Instruction>(V));
67 }
68};
69
70} // End llvm namespace
71
72#endif