Skip to content

Commit cfb7c1d

Browse files
author
Michael Skvortsov
committed
Drop hiddenstack intrinsic
1 parent a7f20b5 commit cfb7c1d

File tree

10 files changed

+12
-68
lines changed

10 files changed

+12
-68
lines changed

llvm/include/llvm/IR/IntrinsicsTVM.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,4 @@ let TargetPrefix = "tvm" in {
674674
foreach i = 1-255 in
675675
def int_tvm_unpackfirst#i : GCCBuiltin<"__builtin_tvm_unpackfirst"#i>,
676676
Intrinsic<!listsplat(llvm_i257_ty, i), [llvm_TVMTuple_ty], [IntrNoMem]>;
677-
678-
def int_tvm_hiddenstack :
679-
GCCBuiltin<"__builtin_tvm_hiddenstack">,
680-
Intrinsic<[llvm_i257_ty], [llvm_i257_ty], [IntrNoMem]>;
681677
}

llvm/lib/Target/TVM/TVMInstrInfo.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@ defm PU2XC : SI<(ins stack_op:$i, stack_op:$j, stack_op:$k),
237237
defm PUSH3 : SI<(ins stack_op:$i, stack_op:$j, stack_op:$k),
238238
"PUSH3\t$i, $j, $k", 0x547>;
239239

240-
let isPseudo=1 in
241-
def HIDDENSTACK : NI<(outs I257:$dst), (ins uimm8:$src), [(set I257:$dst, (int_tvm_hiddenstack uimm8:$src))], 1>;
242-
243240
defm POP : SI<(ins stack_op:$dst), "POP\t$dst", 0x30>;
244241
defm DROP : SI<(ins), "DROP", 0x30>;
245242
defm BLKDROP : SI<(ins uimm8:$sz), "BLKDROP\t$sz", 0x5F0>;

llvm/lib/Target/TVM/TVMStack.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ Stack& Stack::operator += (const StackFixup::Change &change) {
154154
std::swap(Data[v.i], Data[v.j]);
155155
},
156156
[this](StackFixup::pushI v){ Data.push_front(Data[v.i]); },
157-
[ ](StackFixup::pushHidden v){ },
158157
[this](StackFixup::pushUndef){
159158
Data.push_front(StackVreg(TVMFunctionInfo::UnusedReg));
160159
},

llvm/lib/Target/TVM/TVMStackFixup.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,6 @@ StackFixup StackFixup::DiffForArgs(const Stack &From, const MIArgs &Args,
455455
return rv;
456456
}
457457

458-
StackFixup StackFixup::DiffForHiddenStack(const Stack &Src, size_t Element,
459-
unsigned OutRegister) {
460-
Stack CurrentStack(Src);
461-
StackFixup rv;
462-
rv(CurrentStack += rv(pushHidden(Src.size() + Element, OutRegister)));
463-
return rv;
464-
}
465-
466458
void StackFixup::apply(Stack &stack) const {
467459
for (auto p : Changes)
468460
stack += p.first;
@@ -597,7 +589,6 @@ void StackFixup::printElem(raw_ostream &OS, const Change &change) const {
597589
[&](xchgTop v) { OS << "xchg s(" << v.i << ")"; },
598590
[&](xchg v) { OS << "xchg s(" << v.i << "), s(" << v.j << ")"; },
599591
[&](pushI v) { OS << "push s(" << v.i << ")"; },
600-
[&](pushHidden v) { OS << "push s(" << v.i << ")"; },
601592
[&](pushUndef) { OS << "zero"; },
602593
[&](blkswap v) { OS << "blkswap " << v.deepSz << ", " << v.topSz; },
603594
[&](roll v) {

llvm/lib/Target/TVM/TVMStackFixup.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ class StackFixup {
6363
static StackFixup DiffForArgs(const Stack &Src, const MIArgs &Args,
6464
bool IsCommutative = false);
6565

66-
static StackFixup DiffForHiddenStack(const Stack &Src, size_t Element,
67-
unsigned OutRegister);
68-
6966
void apply(Stack &stack) const;
7067

7168
// Remove one copy of this elem
@@ -109,12 +106,6 @@ class StackFixup {
109106
}
110107
unsigned i;
111108
};
112-
struct pushHidden : pushI {
113-
explicit pushHidden(unsigned i, unsigned reg, bool checkLimits = true)
114-
: pushI(i, checkLimits), reg(reg) {}
115-
unsigned i;
116-
unsigned reg;
117-
};
118109
struct dup : pushI {
119110
dup() : pushI(0) {}
120111
};
@@ -251,8 +242,8 @@ class StackFixup {
251242
: tripleChange(true, true, false, i, j, k) {}
252243
};
253244
using Change =
254-
std::variant<drop, nip, xchgTop, xchg, pushI, pushHidden, pushUndef,
255-
blkswap, blkdrop, roll, reverse, doubleChange, tripleChange>;
245+
std::variant<drop, nip, xchgTop, xchg, pushI, pushUndef, blkswap, blkdrop,
246+
roll, reverse, doubleChange, tripleChange>;
256247
using ChangesVec = std::vector<std::pair<Change, std::string>>;
257248

258249
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

llvm/lib/Target/TVM/TVMStackModel.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,6 @@ StackFixup TVMStackModel::prepareStackFor(MachineInstr &MI,
525525
if (MI.isImplicitDef())
526526
return {};
527527

528-
if (MI.getOpcode() == TVM::HIDDENSTACK) {
529-
auto Result = MI.getOperand(0);
530-
auto Operand = MI.getOperand(1);
531-
assert(Result.isReg() && Operand.isCImm() && "Unexpected instruction format");
532-
return StackFixup::DiffForHiddenStack(StackBefore,
533-
Operand.getCImm()->getZExtValue(),
534-
Result.getReg());
535-
}
536-
537528
auto *MBB = MI.getParent();
538529

539530
#ifndef NDEBUG

llvm/test/CodeGen/TVM/hiddenstack.ll

Lines changed: 0 additions & 28 deletions
This file was deleted.

llvm/tools/clang/include/clang/Basic/BuiltinsTVM.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,5 @@ BUILTIN(__builtin_tvm_unpackfirst252, "T252Tt", "nc")
703703
BUILTIN(__builtin_tvm_unpackfirst253, "T253Tt", "nc")
704704
BUILTIN(__builtin_tvm_unpackfirst254, "T254Tt", "nc")
705705
BUILTIN(__builtin_tvm_unpackfirst255, "T255Tt", "nc")
706-
BUILTIN(__builtin_tvm_hiddenstack, "WiWi", "nc")
707706

708707
#undef BUILTIN

stdlib/stdlib_c.tvm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ tvm_sender_pubkey:
8888

8989
PUSH s1
9090
SETGLOB 7
91+
PUSH s2
92+
SETGLOB 8
93+
PUSH s3
94+
SETGLOB 9
9195

9296
PUSHCONT {
9397
CALL $load_macro$
@@ -135,6 +139,10 @@ tvm_sender_pubkey:
135139

136140
PUSH s1
137141
SETGLOB 7
142+
PUSH s2
143+
SETGLOB 8
144+
PUSH s3
145+
SETGLOB 9
138146

139147
PUSHCONT {
140148
CALL $load_macro$

stdlib/ton-sdk/smart-contract-info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ SmartContractInfo get_SmartContractInfo () {
99
#include "smart-contract-info.inc"
1010

1111
unsigned contract_balance() {
12-
return __builtin_tvm_hiddenstack(4);
12+
return __builtin_tvm_getglobal(9);
1313
}
1414

1515
unsigned message_balance() {
16-
return __builtin_tvm_hiddenstack(3);
16+
return __builtin_tvm_getglobal(8);
1717
}

0 commit comments

Comments
 (0)