llvm.org GIT mirror llvm / ce51720
Move ArgFlagsTy, OutputArg, and InputArg out of SelectionDAGNodes.h and into a new header, TargetCallingConv.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107782 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
4 changed file(s) with 163 addition(s) and 139 deletion(s). Raw diff Collapse all Expand all
1616
1717 #include "llvm/ADT/SmallVector.h"
1818 #include "llvm/CodeGen/ValueTypes.h"
19 #include "llvm/CodeGen/SelectionDAGNodes.h"
19 #include "llvm/Target/TargetCallingConv.h"
2020 #include "llvm/CallingConv.h"
2121
2222 namespace llvm {
14631463 }
14641464 };
14651465
1466 namespace ISD {
1467 struct ArgFlagsTy {
1468 private:
1469 static const uint64_t NoFlagSet = 0ULL;
1470 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
1471 static const uint64_t ZExtOffs = 0;
1472 static const uint64_t SExt = 1ULL<<1; ///< Sign extended
1473 static const uint64_t SExtOffs = 1;
1474 static const uint64_t InReg = 1ULL<<2; ///< Passed in register
1475 static const uint64_t InRegOffs = 2;
1476 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
1477 static const uint64_t SRetOffs = 3;
1478 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
1479 static const uint64_t ByValOffs = 4;
1480 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
1481 static const uint64_t NestOffs = 5;
1482 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment
1483 static const uint64_t ByValAlignOffs = 6;
1484 static const uint64_t Split = 1ULL << 10;
1485 static const uint64_t SplitOffs = 10;
1486 static const uint64_t OrigAlign = 0x1FULL<<27;
1487 static const uint64_t OrigAlignOffs = 27;
1488 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size
1489 static const uint64_t ByValSizeOffs = 32;
1490
1491 static const uint64_t One = 1ULL; //< 1 of this type, for shifts
1492
1493 uint64_t Flags;
1494 public:
1495 ArgFlagsTy() : Flags(0) { }
1496
1497 bool isZExt() const { return Flags & ZExt; }
1498 void setZExt() { Flags |= One << ZExtOffs; }
1499
1500 bool isSExt() const { return Flags & SExt; }
1501 void setSExt() { Flags |= One << SExtOffs; }
1502
1503 bool isInReg() const { return Flags & InReg; }
1504 void setInReg() { Flags |= One << InRegOffs; }
1505
1506 bool isSRet() const { return Flags & SRet; }
1507 void setSRet() { Flags |= One << SRetOffs; }
1508
1509 bool isByVal() const { return Flags & ByVal; }
1510 void setByVal() { Flags |= One << ByValOffs; }
1511
1512 bool isNest() const { return Flags & Nest; }
1513 void setNest() { Flags |= One << NestOffs; }
1514
1515 unsigned getByValAlign() const {
1516 return (unsigned)
1517 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
1518 }
1519 void setByValAlign(unsigned A) {
1520 Flags = (Flags & ~ByValAlign) |
1521 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
1522 }
1523
1524 bool isSplit() const { return Flags & Split; }
1525 void setSplit() { Flags |= One << SplitOffs; }
1526
1527 unsigned getOrigAlign() const {
1528 return (unsigned)
1529 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
1530 }
1531 void setOrigAlign(unsigned A) {
1532 Flags = (Flags & ~OrigAlign) |
1533 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
1534 }
1535
1536 unsigned getByValSize() const {
1537 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
1538 }
1539 void setByValSize(unsigned S) {
1540 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
1541 }
1542
1543 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
1544 std::string getArgFlagsString();
1545
1546 /// getRawBits - Represent the flags as a bunch of bits.
1547 uint64_t getRawBits() const { return Flags; }
1548 };
1549
1550 /// InputArg - This struct carries flags and type information about a
1551 /// single incoming (formal) argument or incoming (from the perspective
1552 /// of the caller) return value virtual register.
1553 ///
1554 struct InputArg {
1555 ArgFlagsTy Flags;
1556 EVT VT;
1557 bool Used;
1558
1559 InputArg() : VT(MVT::Other), Used(false) {}
1560 InputArg(ISD::ArgFlagsTy flags, EVT vt, bool used)
1561 : Flags(flags), VT(vt), Used(used) {
1562 assert(VT.isSimple() &&
1563 "InputArg value type must be Simple!");
1564 }
1565 };
1566
1567 /// OutputArg - This struct carries flags and a value for a
1568 /// single outgoing (actual) argument or outgoing (from the perspective
1569 /// of the caller) return value virtual register.
1570 ///
1571 struct OutputArg {
1572 ArgFlagsTy Flags;
1573 SDValue Val;
1574
1575 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
1576 bool IsFixed;
1577
1578 OutputArg() : IsFixed(false) {}
1579 OutputArg(ISD::ArgFlagsTy flags, SDValue val, bool isfixed)
1580 : Flags(flags), Val(val), IsFixed(isfixed) {
1581 assert(Val.getValueType().isSimple() &&
1582 "OutputArg value type must be Simple!");
1583 }
1584 };
1585
1586 /// OutputArgReg - This struct carries flags and a register value for a
1587 /// single outgoing (actual) argument or outgoing (from the perspective
1588 /// of the caller) return value virtual register.
1589 ///
1590 struct OutputArgReg {
1591 ArgFlagsTy Flags;
1592 EVT VT;
1593 unsigned Reg;
1594
1595 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
1596 bool IsFixed;
1597
1598 OutputArgReg() : IsFixed(false) {}
1599 OutputArgReg(ISD::ArgFlagsTy flags, EVT vt, unsigned reg, bool isfixed)
1600 : Flags(flags), VT(vt), Reg(reg), IsFixed(isfixed) {}
1601 };
1602 }
1603
16041466 /// VTSDNode - This class is used to represent EVT's, which are used
16051467 /// to parameterize some operations.
16061468 class VTSDNode : public SDNode {
0 //===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- 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 defines types for working with calling-convention information.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
14 #define LLVM_TARGET_TARGETCALLINGCONV_H
15
16 #include "llvm/CodeGen/SelectionDAGNodes.h"
17
18 namespace llvm {
19
20 namespace ISD {
21 struct ArgFlagsTy {
22 private:
23 static const uint64_t NoFlagSet = 0ULL;
24 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
25 static const uint64_t ZExtOffs = 0;
26 static const uint64_t SExt = 1ULL<<1; ///< Sign extended
27 static const uint64_t SExtOffs = 1;
28 static const uint64_t InReg = 1ULL<<2; ///< Passed in register
29 static const uint64_t InRegOffs = 2;
30 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
31 static const uint64_t SRetOffs = 3;
32 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
33 static const uint64_t ByValOffs = 4;
34 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
35 static const uint64_t NestOffs = 5;
36 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment
37 static const uint64_t ByValAlignOffs = 6;
38 static const uint64_t Split = 1ULL << 10;
39 static const uint64_t SplitOffs = 10;
40 static const uint64_t OrigAlign = 0x1FULL<<27;
41 static const uint64_t OrigAlignOffs = 27;
42 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size
43 static const uint64_t ByValSizeOffs = 32;
44
45 static const uint64_t One = 1ULL; //< 1 of this type, for shifts
46
47 uint64_t Flags;
48 public:
49 ArgFlagsTy() : Flags(0) { }
50
51 bool isZExt() const { return Flags & ZExt; }
52 void setZExt() { Flags |= One << ZExtOffs; }
53
54 bool isSExt() const { return Flags & SExt; }
55 void setSExt() { Flags |= One << SExtOffs; }
56
57 bool isInReg() const { return Flags & InReg; }
58 void setInReg() { Flags |= One << InRegOffs; }
59
60 bool isSRet() const { return Flags & SRet; }
61 void setSRet() { Flags |= One << SRetOffs; }
62
63 bool isByVal() const { return Flags & ByVal; }
64 void setByVal() { Flags |= One << ByValOffs; }
65
66 bool isNest() const { return Flags & Nest; }
67 void setNest() { Flags |= One << NestOffs; }
68
69 unsigned getByValAlign() const {
70 return (unsigned)
71 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
72 }
73 void setByValAlign(unsigned A) {
74 Flags = (Flags & ~ByValAlign) |
75 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
76 }
77
78 bool isSplit() const { return Flags & Split; }
79 void setSplit() { Flags |= One << SplitOffs; }
80
81 unsigned getOrigAlign() const {
82 return (unsigned)
83 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
84 }
85 void setOrigAlign(unsigned A) {
86 Flags = (Flags & ~OrigAlign) |
87 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
88 }
89
90 unsigned getByValSize() const {
91 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
92 }
93 void setByValSize(unsigned S) {
94 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
95 }
96
97 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
98 std::string getArgFlagsString();
99
100 /// getRawBits - Represent the flags as a bunch of bits.
101 uint64_t getRawBits() const { return Flags; }
102 };
103
104 /// InputArg - This struct carries flags and type information about a
105 /// single incoming (formal) argument or incoming (from the perspective
106 /// of the caller) return value virtual register.
107 ///
108 struct InputArg {
109 ArgFlagsTy Flags;
110 EVT VT;
111 bool Used;
112
113 InputArg() : VT(MVT::Other), Used(false) {}
114 InputArg(ISD::ArgFlagsTy flags, EVT vt, bool used)
115 : Flags(flags), VT(vt), Used(used) {
116 assert(VT.isSimple() &&
117 "InputArg value type must be Simple!");
118 }
119 };
120
121 /// OutputArg - This struct carries flags and a value for a
122 /// single outgoing (actual) argument or outgoing (from the perspective
123 /// of the caller) return value virtual register.
124 ///
125 struct OutputArg {
126 ArgFlagsTy Flags;
127 SDValue Val;
128
129 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
130 bool IsFixed;
131
132 OutputArg() : IsFixed(false) {}
133 OutputArg(ISD::ArgFlagsTy flags, SDValue val, bool isfixed)
134 : Flags(flags), Val(val), IsFixed(isfixed) {
135 assert(Val.getValueType().isSimple() &&
136 "OutputArg value type must be Simple!");
137 }
138 };
139
140 /// OutputArgReg - This struct carries flags and a register value for a
141 /// single outgoing (actual) argument or outgoing (from the perspective
142 /// of the caller) return value virtual register.
143 ///
144 struct OutputArgReg {
145 ArgFlagsTy Flags;
146 EVT VT;
147 unsigned Reg;
148
149 /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
150 bool IsFixed;
151
152 OutputArgReg() : IsFixed(false) {}
153 OutputArgReg(ISD::ArgFlagsTy flags, EVT vt, unsigned reg, bool isfixed)
154 : Flags(flags), VT(vt), Reg(reg), IsFixed(isfixed) {}
155 };
156 }
157
158 } // end llvm namespace
159
160 #endif
3131 #include "llvm/ADT/SmallVector.h"
3232 #include "llvm/ADT/STLExtras.h"
3333 #include "llvm/Support/DebugLoc.h"
34 #include "llvm/Target/TargetCallingConv.h"
3435 #include "llvm/Target/TargetMachine.h"
3536 #include
3637 #include