llvm.org GIT mirror llvm / 9a368b2
[GlobalISel] Introduce a G_DYN_STACKALLOC opcode to represent dynamic allocas. This just adds the opcode and verifier, it will be used to replace existing dynamic alloca handling in a subsequent patch. Differential Revision: https://reviews.llvm.org/D66677 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369833 91177308-0d34-0410-b5e6-96231b3b80d8 Amara Emerson 28 days ago
4 changed file(s) with 56 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
589589 /// Generic jump table address
590590 HANDLE_TARGET_OPCODE(G_JUMP_TABLE)
591591
592 /// Generic dynamic stack allocation.
593 HANDLE_TARGET_OPCODE(G_DYN_STACKALLOC)
594
592595 // TODO: Add more generic opcodes as we move along.
593596
594597 /// Marker for the end of the generic opcode.
595598 /// This is used to check if an opcode is in the range of the
596599 /// generic opcodes.
597 HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_JUMP_TABLE)
600 HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_DYN_STACKALLOC)
598601
599602 /// BUILTIN_OP_END - This must be the last enum value in this list.
600603 /// The target-specific post-isel opcode values start here.
186186 let OutOperandList = (outs type0:$dst);
187187 let InOperandList = (ins unknown:$jti);
188188 let hasSideEffects = 0;
189 }
190
191 def G_DYN_STACKALLOC : GenericInstruction {
192 let OutOperandList = (outs ptype0:$dst);
193 let InOperandList = (ins type1:$size, i32imm:$align);
194 let hasSideEffects = 1;
189195 }
190196
191197 //------------------------------------------------------------------------------
14361436
14371437 break;
14381438 }
1439 case TargetOpcode::G_DYN_STACKALLOC: {
1440 const MachineOperand &DstOp = MI->getOperand(0);
1441 const MachineOperand &AllocOp = MI->getOperand(1);
1442 const MachineOperand &AlignOp = MI->getOperand(2);
1443
1444 if (!DstOp.isReg() || !MRI->getType(DstOp.getReg()).isPointer()) {
1445 report("dst operand 0 must be a pointer type", MI);
1446 break;
1447 }
1448
1449 if (!AllocOp.isReg() || !MRI->getType(AllocOp.getReg()).isScalar()) {
1450 report("src operand 1 must be a scalar reg type", MI);
1451 break;
1452 }
1453
1454 if (!AlignOp.isImm()) {
1455 report("src operand 2 must be an immediate type", MI);
1456 break;
1457 }
1458 break;
1459 }
14391460 default:
14401461 break;
14411462 }
0 # RUN: not llc -march=aarch64 -o /dev/null -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
1 # REQUIRES: global-isel, aarch64-registered-target
2
3 ---
4 name: test_dyn_stackalloc
5 legalized: true
6 tracksRegLiveness: true
7 body: |
8 bb.0:
9 liveins: $x0
10 %0:_(s64) = COPY $x0
11 %1:_(p0) = COPY $x0
12 ; CHECK: Bad machine code: Too few operands
13 G_DYN_STACKALLOC
14
15 ; CHECK: dst operand 0 must be a pointer type
16 %3:_(s64) = G_DYN_STACKALLOC %0, 4
17
18 ; CHECK: src operand 1 must be a scalar reg type
19 %4:_(p0) = G_DYN_STACKALLOC 0, 4
20
21 ; CHECK: src operand 2 must be an immediate type
22 %5:_(p0) = G_DYN_STACKALLOC %0, %0
23
24 ...