forked from OSchip/llvm-project
[WebAssembly] Fix reftype load/store match with idx from call
Implement support for matching an index from a WebAssembly CALL instruction. Add test. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D115327
This commit is contained in:
parent
821dd3b0e5
commit
97ef15ad76
|
@ -1491,8 +1491,7 @@ bool WebAssemblyTargetLowering::MatchTableForLowering(SelectionDAG &DAG,
|
|||
if (GA) {
|
||||
// We are in Case 2 above.
|
||||
Idx = Base->getOperand(1);
|
||||
if (!Idx || GA->getNumValues() != 1 || Idx->getNumValues() != 1)
|
||||
return false;
|
||||
assert(GA->getNumValues() == 1);
|
||||
} else {
|
||||
// This might be Case 1 above (or an error)
|
||||
SDValue V = Base->getOperand(0);
|
||||
|
|
|
@ -79,4 +79,19 @@ define void @set_externref_table_with_var_offset2(%externref %g, i32 %i) {
|
|||
ret void
|
||||
}
|
||||
|
||||
declare i32 @get_table_slot() local_unnamed_addr
|
||||
|
||||
define void @set_externref_table_with_id_from_call(%externref %g) {
|
||||
; CHECK-LABEL: set_externref_table_with_id_from_call:
|
||||
; CHECK-NEXT: .functype set_externref_table_with_id_from_call (externref) -> ()
|
||||
; CHECK-NEXT: call get_table_slot
|
||||
; CHECK-NEXT: local.get 0
|
||||
; CHECK-NEXT: table.set externref_table
|
||||
; CHECK-NEXT: end_function
|
||||
%id = call i32 @get_table_slot()
|
||||
%p = getelementptr [0 x %externref], [0 x %externref] addrspace (1)* @externref_table, i32 0, i32 %id
|
||||
store %externref %g, %externref addrspace(1)* %p
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: .tabletype externref_table, externref
|
||||
|
|
Loading…
Reference in New Issue