llvm.org GIT mirror llvm / 36b5c13
Rename MemOperand to MachineMemOperand. This was suggested by review feedback from Chris quite a while ago. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49348 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 12 years ago
12 changed file(s) with 121 addition(s) and 120 deletion(s). Raw diff Collapse all Expand all
1616 #define LLVM_CODEGEN_MACHINEINSTR_H
1717
1818 #include "llvm/CodeGen/MachineOperand.h"
19 #include "llvm/CodeGen/MemOperand.h"
19 #include "llvm/CodeGen/MachineMemOperand.h"
2020
2121 namespace llvm {
2222
3636 // are determined at construction time).
3737
3838 std::vector Operands; // the operands
39 std::vectoremOperand> MemOperands; // information on memory references
39 std::vectorachineMemOperand> MemOperands;// information on memory references
4040 MachineInstr *Prev, *Next; // Links for MBB's intrusive list.
4141 MachineBasicBlock *Parent; // Pointer to the owning basic block.
4242
9999 /// Access to memory operands of the instruction
100100 unsigned getNumMemOperands() const { return MemOperands.size(); }
101101
102 const MemOperand& getMemOperand(unsigned i) const {
102 const MachineMemOperand& getMemOperand(unsigned i) const {
103103 assert(i < getNumMemOperands() && "getMemOperand() out of range!");
104104 return MemOperands[i];
105105 }
106 MemOperand& getMemOperand(unsigned i) {
106 MachineMemOperand& getMemOperand(unsigned i) {
107107 assert(i < getNumMemOperands() && "getMemOperand() out of range!");
108108 return MemOperands[i];
109109 }
267267 ///
268268 void RemoveOperand(unsigned i);
269269
270 /// addMemOperand - Add a MemOperand to the machine instruction, referencing
271 /// arbitrary storage.
272 void addMemOperand(const MemOperand &MO) {
270 /// addMemOperand - Add a MachineMemOperand to the machine instruction,
271 /// referencing arbitrary storage.
272 void addMemOperand(const MachineMemOperand &MO) {
273273 MemOperands.push_back(MO);
274274 }
275275
8484 }
8585
8686 /// addMemOperand - Add a memory operand to the machine instruction.
87 const MachineInstrBuilder &addMemOperand(const MemOperand &MO) const {
87 const MachineInstrBuilder &addMemOperand(const MachineMemOperand &MO) const {
8888 MI->addMemOperand(MO);
8989 return *this;
9090 }
0 //==- llvm/CodeGen/MachineMemOperand.h - MachineMemOperand class -*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the MachineMemOperand class, which is a
10 // description of a memory reference. It is used to help track dependencies
11 // in the backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_MEMOPERAND_H
16 #define LLVM_CODEGEN_MEMOPERAND_H
17
18 namespace llvm {
19
20 class Value;
21
22 //===----------------------------------------------------------------------===//
23 /// MachineMemOperand - A description of a memory reference used in the backend.
24 /// Instead of holding a StoreInst or LoadInst, this class holds the address
25 /// Value of the reference along with a byte size and offset. This allows it
26 /// to describe lowered loads and stores. Also, the special PseudoSourceValue
27 /// objects can be used to represent loads and stores to memory locations
28 /// that aren't explicit in the regular LLVM IR.
29 ///
30 class MachineMemOperand {
31 const Value *V;
32 unsigned int Flags;
33 int64_t Offset;
34 uint64_t Size;
35 unsigned int Alignment;
36
37 public:
38 /// Flags values. These may be or'd together.
39 enum MemOperandFlags {
40 /// The memory access reads data.
41 MOLoad = 1,
42 /// The memory access writes data.
43 MOStore = 2,
44 /// The memory access is volatile.
45 MOVolatile = 4
46 };
47
48 /// MachineMemOperand - Construct an MachineMemOperand object with the
49 /// specified address Value, flags, offset, size, and alignment.
50 MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s,
51 unsigned int a)
52 : V(v), Flags(f), Offset(o), Size(s), Alignment(a) {}
53
54 /// getValue - Return the base address of the memory access.
55 /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel,
56 /// and the other PseudoSourceValue members which indicate references to
57 /// frame/stack pointer relative references and other special references.
58 const Value *getValue() const { return V; }
59
60 /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
61 unsigned int getFlags() const { return Flags; }
62
63 /// getOffset - For normal values, this is a byte offset added to the base
64 /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
65 /// number.
66 int64_t getOffset() const { return Offset; }
67
68 /// getSize - Return the size in bytes of the memory reference.
69 uint64_t getSize() const { return Size; }
70
71 /// getAlignment - Return the minimum known alignment in bytes of the
72 /// memory reference.
73 unsigned int getAlignment() const { return Alignment; }
74
75 bool isLoad() const { return Flags & MOLoad; }
76 bool isStore() const { return Flags & MOStore; }
77 bool isVolatile() const { return Flags & MOVolatile; }
78 };
79
80 } // End llvm namespace
81
82 #endif
+0
-83
include/llvm/CodeGen/MemOperand.h less more
None //===-- llvm/CodeGen/MemOperand.h - MemOperand class ------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the MemOperand class, which is a
10 // description of a memory reference. It is used to help track dependencies
11 // in the backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_MEMOPERAND_H
16 #define LLVM_CODEGEN_MEMOPERAND_H
17
18 namespace llvm {
19
20 class Value;
21
22 //===----------------------------------------------------------------------===//
23 /// MemOperand - A description of a memory reference used in the backend.
24 /// Instead of holding a StoreInst or LoadInst, this class holds the address
25 /// Value of the reference along with a byte size and offset. This allows it
26 /// to describe lowered loads and stores. Also, the special PseudoSourceValue
27 /// objects can be used to represent loads and stores to memory locations
28 /// that aren't explicit in the regular LLVM IR.
29 ///
30 class MemOperand {
31 const Value *V;
32 unsigned int Flags;
33 int64_t Offset;
34 uint64_t Size;
35 unsigned int Alignment;
36
37 public:
38 /// Flags values. These may be or'd together.
39 enum MemOperandFlags {
40 /// The memory access reads data.
41 MOLoad = 1,
42 /// The memory access writes data.
43 MOStore = 2,
44 /// The memory access is volatile.
45 MOVolatile = 4
46 };
47
48 /// MemOperand - Construct an MemOperand object with the specified
49 /// address Value, flags, offset, size, and alignment.
50 MemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s,
51 unsigned int a)
52 : V(v), Flags(f), Offset(o), Size(s), Alignment(a) {}
53
54 /// getValue - Return the base address of the memory access.
55 /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel,
56 /// and the other PseudoSourceValue members which indicate references to
57 /// frame/stack pointer relative references and other special references.
58 const Value *getValue() const { return V; }
59
60 /// getFlags - Return the raw flags of the source value, \see MemOperandFlags.
61 unsigned int getFlags() const { return Flags; }
62
63 /// getOffset - For normal values, this is a byte offset added to the base
64 /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex
65 /// number.
66 int64_t getOffset() const { return Offset; }
67
68 /// getSize - Return the size in bytes of the memory reference.
69 uint64_t getSize() const { return Size; }
70
71 /// getAlignment - Return the minimum known alignment in bytes of the
72 /// memory reference.
73 unsigned int getAlignment() const { return Alignment; }
74
75 bool isLoad() const { return Flags & MOLoad; }
76 bool isStore() const { return Flags & MOStore; }
77 bool isVolatile() const { return Flags & MOVolatile; }
78 };
79
80 } // End llvm namespace
81
82 #endif
364364 const TargetInstrDesc *II,
365365 DenseMap &VRBaseMap);
366366
367 void AddMemOperand(MachineInstr *MI, const MemOperand &MO);
367 void AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO);
368368
369369 void EmitCrossRCCopy(SUnit *SU, DenseMap &VRBaseMap);
370370
400400
401401 // getMemOperand - Construct a node to track a memory reference
402402 // through the backend.
403 SDOperand getMemOperand(const MemOperand &MO);
403 SDOperand getMemOperand(const MachineMemOperand &MO);
404404
405405 /// UpdateNodeOperands - *Mutate* the specified node in-place to have the
406406 /// specified operands. If the resultant node already exists in the DAG,
2525 #include "llvm/ADT/APFloat.h"
2626 #include "llvm/ADT/APInt.h"
2727 #include "llvm/CodeGen/ValueTypes.h"
28 #include "llvm/CodeGen/MemOperand.h"
28 #include "llvm/CodeGen/MachineMemOperand.h"
2929 #include "llvm/Support/DataTypes.h"
3030 #include
3131
529529 // make reference to a value in the LLVM IR.
530530 SRCVALUE,
531531
532 // MEMOPERAND - This is a node that contains a MemOperand which records
533 // information about a memory reference. This is used to make AliasAnalysis
534 // queries from the backend.
532 // MEMOPERAND - This is a node that contains a MachineMemOperand which
533 // records information about a memory reference. This is used to make
534 // AliasAnalysis queries from the backend.
535535 MEMOPERAND,
536536
537537 // PCMARKER - This corresponds to the pcmarker intrinsic.
16441644 };
16451645
16461646
1647 /// MemOperandSDNode - An SDNode that holds a MemOperand. This is
1647 /// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
16481648 /// used to represent a reference to memory after ISD::LOAD
16491649 /// and ISD::STORE have been lowered.
16501650 ///
16521652 virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
16531653 protected:
16541654 friend class SelectionDAG;
1655 /// Create a MemOperand node
1656 explicit MemOperandSDNode(const MemOperand &mo)
1655 /// Create a MachineMemOperand node
1656 explicit MemOperandSDNode(const MachineMemOperand &mo)
16571657 : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
16581658
16591659 public:
1660 /// MO - The contained MemOperand.
1661 const MemOperand MO;
1660 /// MO - The contained MachineMemOperand.
1661 const MachineMemOperand MO;
16621662
16631663 static bool classof(const MemOperandSDNode *) { return true; }
16641664 static bool classof(const SDNode *N) {
19051905 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
19061906 bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; }
19071907
1908 /// getMemOperand - Return a MemOperand object describing the memory
1908 /// getMemOperand - Return a MachineMemOperand object describing the memory
19091909 /// reference performed by this load or store.
1910 MemOperand getMemOperand() const;
1910 MachineMemOperand getMemOperand() const;
19111911
19121912 static bool classof(const LSBaseSDNode *N) { return true; }
19131913 static bool classof(const SDNode *N) {
692692 if (getNumMemOperands() > 0) {
693693 OS << ", Mem:";
694694 for (unsigned i = 0; i < getNumMemOperands(); i++) {
695 const MemOperand &MRO = getMemOperand(i);
695 const MachineMemOperand &MRO = getMemOperand(i);
696696 const Value *V = MRO.getValue();
697697
698698 assert((MRO.isLoad() || MRO.isStore()) &&
368368 unsigned ScheduleDAG::CountOperands(SDNode *Node) {
369369 unsigned N = ComputeMemOperandsEnd(Node);
370370 while (N && isa(Node->getOperand(N - 1).Val))
371 --N; // Ignore MemOperand nodes
371 --N; // Ignore MEMOPERAND nodes
372372 return N;
373373 }
374374
655655
656656 }
657657
658 void ScheduleDAG::AddMemOperand(MachineInstr *MI, const MemOperand &MO) {
658 void ScheduleDAG::AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO) {
659659 MI->addMemOperand(MO);
660660 }
661661
384384 ID.AddPointer(cast(N)->getValue());
385385 break;
386386 case ISD::MEMOPERAND: {
387 const MemOperand &MO = cast(N)->MO;
387 const MachineMemOperand &MO = cast(N)->MO;
388388 ID.AddPointer(MO.getValue());
389389 ID.AddInteger(MO.getFlags());
390390 ID.AddInteger(MO.getOffset());
10131013 return SDOperand(N, 0);
10141014 }
10151015
1016 SDOperand SelectionDAG::getMemOperand(const MemOperand &MO) {
1016 SDOperand SelectionDAG::getMemOperand(const MachineMemOperand &MO) {
10171017 const Value *v = MO.getValue();
10181018 assert((!v || isa(v->getType())) &&
10191019 "SrcValue is not a pointer?");
36343634 TheGlobal = const_cast(GA);
36353635 }
36363636
3637 /// getMemOperand - Return a MemOperand object describing the memory
3637 /// getMemOperand - Return a MachineMemOperand object describing the memory
36383638 /// reference performed by this load or store.
3639 MemOperand LSBaseSDNode::getMemOperand() const {
3639 MachineMemOperand LSBaseSDNode::getMemOperand() const {
36403640 int Size = (MVT::getSizeInBits(getMemoryVT()) + 7) >> 3;
36413641 int Flags =
3642 getOpcode() == ISD::LOAD ? MemOperand::MOLoad : MemOperand::MOStore;
3643 if (IsVolatile) Flags |= MemOperand::MOVolatile;
3642 getOpcode() == ISD::LOAD ? MachineMemOperand::MOLoad :
3643 MachineMemOperand::MOStore;
3644 if (IsVolatile) Flags |= MachineMemOperand::MOVolatile;
36443645
36453646 // Check if the load references a frame index, and does not have
36463647 // an SV attached.
36473648 const FrameIndexSDNode *FI =
36483649 dyn_cast(getBasePtr().Val);
36493650 if (!getSrcValue() && FI)
3650 return MemOperand(PseudoSourceValue::getFixedStack(), Flags,
3651 FI->getIndex(), Size, Alignment);
3651 return MachineMemOperand(PseudoSourceValue::getFixedStack(), Flags,
3652 FI->getIndex(), Size, Alignment);
36523653 else
3653 return MemOperand(getSrcValue(), Flags,
3654 getSrcValueOffset(), Size, Alignment);
3654 return MachineMemOperand(getSrcValue(), Flags,
3655 getSrcValueOffset(), Size, Alignment);
36553656 }
36563657
36573658 /// Profile - Gather unique data for the node.
24992499 Op.getOperand(0));
25002500
25012501 // STD the extended value into the stack slot.
2502 MemOperand MO(PseudoSourceValue::getFixedStack(),
2503 MemOperand::MOStore, FrameIdx, 8, 8);
2502 MachineMemOperand MO(PseudoSourceValue::getFixedStack(),
2503 MachineMemOperand::MOStore, FrameIdx, 8, 8);
25042504 SDOperand Store = DAG.getNode(PPCISD::STD_32, MVT::Other,
25052505 DAG.getEntryNode(), Ext64, FIdx,
25062506 DAG.getMemOperand(MO));
19291929
19301930 unsigned Alignment = 0;
19311931 for (unsigned i = 0, e = LoadMI->getNumMemOperands(); i != e; ++i) {
1932 const MemOperand &MRO = LoadMI->getMemOperand(i);
1932 const MachineMemOperand &MRO = LoadMI->getMemOperand(i);
19331933 unsigned Align = MRO.getAlignment();
19341934 if (Align > Alignment)
19351935 Alignment = Align;