Skip to content

Commit 72cb7a7

Browse files
authored
lcb: Used field access type instead of architecture's type (#462)
1 parent 2593476 commit 72cb7a7

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

vadl/main/vadl/lcb/passes/llvmLowering/strategies/LlvmInstructionLoweringStrategy.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.stream.Stream;
3131
import javax.annotation.Nonnull;
3232
import javax.annotation.Nullable;
33+
import vadl.cppCodeGen.CppTypeMap;
3334
import vadl.error.DeferredDiagnosticStore;
3435
import vadl.error.Diagnostic;
3536
import vadl.gcb.passes.DetermineRegisterUsesAndDefsPass;
@@ -247,11 +248,15 @@ protected List<GcbInstructionOperand> replaceOperands(
247248
// This branch is taken when the field access was removed from the instruction's behavior
248249
// because of optimisations. However, we still need to replace this operand.
249250
var fieldAccess = immediateOperand.fieldAccess();
251+
var upcastedType =
252+
ValueType.from(CppTypeMap.upcast(fieldAccess.accessFunction().returnType()))
253+
.orElseThrow(
254+
() -> Diagnostic.error("Cannot cast type", fieldAccess.location()).build());
250255
var llvmNode =
251256
new LlvmFieldAccessRefNode(instruction,
252257
fieldAccess,
253258
fieldAccess.type(),
254-
architectureType,
259+
upcastedType,
255260
LlvmFieldAccessRefNode.Usage.Immediate);
256261
operands.set(i, new TableGenInstructionImmediateOperand(llvmNode));
257262
} else if (operand instanceof GcbInstructionRegisterFileOperand registerFileOperand

vadl/test/resources/snapshots/aarch64/InstrInfoTableGen.td

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15413,7 +15413,7 @@ let Size = 4;
1541315413
let CodeSize = 4;
1541415414

1541515415
let OutOperandList = ( outs );
15416-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNALW_nzcvAsInt64:$nzcv );
15416+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNALW_nzcvAsInt8:$nzcv );
1541715417

1541815418
field bits<32> Inst;
1541915419

@@ -15468,7 +15468,7 @@ let Size = 4;
1546815468
let CodeSize = 4;
1546915469

1547015470
let OutOperandList = ( outs );
15471-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNALX_nzcvAsInt64:$nzcv );
15471+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNALX_nzcvAsInt8:$nzcv );
1547215472

1547315473
field bits<32> Inst;
1547415474

@@ -16183,7 +16183,7 @@ let Size = 4;
1618316183
let CodeSize = 4;
1618416184

1618516185
let OutOperandList = ( outs );
16186-
let InOperandList = ( ins S:$rn, AArch64Base_CCMNIALW_immXAsInt64:$immX, AArch64Base_CCMNIALW_nzcvAsInt64:$nzcv );
16186+
let InOperandList = ( ins S:$rn, AArch64Base_CCMNIALW_immXAsInt64:$immX, AArch64Base_CCMNIALW_nzcvAsInt8:$nzcv );
1618716187

1618816188
field bits<32> Inst;
1618916189

@@ -16238,7 +16238,7 @@ let Size = 4;
1623816238
let CodeSize = 4;
1623916239

1624016240
let OutOperandList = ( outs );
16241-
let InOperandList = ( ins S:$rn, AArch64Base_CCMNIALX_immXAsInt64:$immX, AArch64Base_CCMNIALX_nzcvAsInt64:$nzcv );
16241+
let InOperandList = ( ins S:$rn, AArch64Base_CCMNIALX_immXAsInt64:$immX, AArch64Base_CCMNIALX_nzcvAsInt8:$nzcv );
1624216242

1624316243
field bits<32> Inst;
1624416244

@@ -17503,7 +17503,7 @@ let Size = 4;
1750317503
let CodeSize = 4;
1750417504

1750517505
let OutOperandList = ( outs );
17506-
let InOperandList = ( ins S:$rn, AArch64Base_CCMNINVW_immXAsInt64:$immX, AArch64Base_CCMNINVW_nzcvAsInt64:$nzcv );
17506+
let InOperandList = ( ins S:$rn, AArch64Base_CCMNINVW_immXAsInt64:$immX, AArch64Base_CCMNINVW_nzcvAsInt8:$nzcv );
1750717507

1750817508
field bits<32> Inst;
1750917509

@@ -17558,7 +17558,7 @@ let Size = 4;
1755817558
let CodeSize = 4;
1755917559

1756017560
let OutOperandList = ( outs );
17561-
let InOperandList = ( ins S:$rn, AArch64Base_CCMNINVX_immXAsInt64:$immX, AArch64Base_CCMNINVX_nzcvAsInt64:$nzcv );
17561+
let InOperandList = ( ins S:$rn, AArch64Base_CCMNINVX_immXAsInt64:$immX, AArch64Base_CCMNINVX_nzcvAsInt8:$nzcv );
1756217562

1756317563
field bits<32> Inst;
1756417564

@@ -18493,7 +18493,7 @@ let Size = 4;
1849318493
let CodeSize = 4;
1849418494

1849518495
let OutOperandList = ( outs );
18496-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNNVW_nzcvAsInt64:$nzcv );
18496+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNNVW_nzcvAsInt8:$nzcv );
1849718497

1849818498
field bits<32> Inst;
1849918499

@@ -18548,7 +18548,7 @@ let Size = 4;
1854818548
let CodeSize = 4;
1854918549

1855018550
let OutOperandList = ( outs );
18551-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNNVX_nzcvAsInt64:$nzcv );
18551+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMNNVX_nzcvAsInt8:$nzcv );
1855218552

1855318553
field bits<32> Inst;
1855418554

@@ -18933,7 +18933,7 @@ let Size = 4;
1893318933
let CodeSize = 4;
1893418934

1893518935
let OutOperandList = ( outs );
18936-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPALW_nzcvAsInt64:$nzcv );
18936+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPALW_nzcvAsInt8:$nzcv );
1893718937

1893818938
field bits<32> Inst;
1893918939

@@ -18988,7 +18988,7 @@ let Size = 4;
1898818988
let CodeSize = 4;
1898918989

1899018990
let OutOperandList = ( outs );
18991-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPALX_nzcvAsInt64:$nzcv );
18991+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPALX_nzcvAsInt8:$nzcv );
1899218992

1899318993
field bits<32> Inst;
1899418994

@@ -19703,7 +19703,7 @@ let Size = 4;
1970319703
let CodeSize = 4;
1970419704

1970519705
let OutOperandList = ( outs );
19706-
let InOperandList = ( ins S:$rn, AArch64Base_CCMPIALW_immXAsInt64:$immX, AArch64Base_CCMPIALW_nzcvAsInt64:$nzcv );
19706+
let InOperandList = ( ins S:$rn, AArch64Base_CCMPIALW_immXAsInt64:$immX, AArch64Base_CCMPIALW_nzcvAsInt8:$nzcv );
1970719707

1970819708
field bits<32> Inst;
1970919709

@@ -19758,7 +19758,7 @@ let Size = 4;
1975819758
let CodeSize = 4;
1975919759

1976019760
let OutOperandList = ( outs );
19761-
let InOperandList = ( ins S:$rn, AArch64Base_CCMPIALX_immXAsInt64:$immX, AArch64Base_CCMPIALX_nzcvAsInt64:$nzcv );
19761+
let InOperandList = ( ins S:$rn, AArch64Base_CCMPIALX_immXAsInt64:$immX, AArch64Base_CCMPIALX_nzcvAsInt8:$nzcv );
1976219762

1976319763
field bits<32> Inst;
1976419764

@@ -21023,7 +21023,7 @@ let Size = 4;
2102321023
let CodeSize = 4;
2102421024

2102521025
let OutOperandList = ( outs );
21026-
let InOperandList = ( ins S:$rn, AArch64Base_CCMPINVW_immXAsInt64:$immX, AArch64Base_CCMPINVW_nzcvAsInt64:$nzcv );
21026+
let InOperandList = ( ins S:$rn, AArch64Base_CCMPINVW_immXAsInt64:$immX, AArch64Base_CCMPINVW_nzcvAsInt8:$nzcv );
2102721027

2102821028
field bits<32> Inst;
2102921029

@@ -21078,7 +21078,7 @@ let Size = 4;
2107821078
let CodeSize = 4;
2107921079

2108021080
let OutOperandList = ( outs );
21081-
let InOperandList = ( ins S:$rn, AArch64Base_CCMPINVX_immXAsInt64:$immX, AArch64Base_CCMPINVX_nzcvAsInt64:$nzcv );
21081+
let InOperandList = ( ins S:$rn, AArch64Base_CCMPINVX_immXAsInt64:$immX, AArch64Base_CCMPINVX_nzcvAsInt8:$nzcv );
2108221082

2108321083
field bits<32> Inst;
2108421084

@@ -22013,7 +22013,7 @@ let Size = 4;
2201322013
let CodeSize = 4;
2201422014

2201522015
let OutOperandList = ( outs );
22016-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPNVW_nzcvAsInt64:$nzcv );
22016+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPNVW_nzcvAsInt8:$nzcv );
2201722017

2201822018
field bits<32> Inst;
2201922019

@@ -22068,7 +22068,7 @@ let Size = 4;
2206822068
let CodeSize = 4;
2206922069

2207022070
let OutOperandList = ( outs );
22071-
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPNVX_nzcvAsInt64:$nzcv );
22071+
let InOperandList = ( ins S:$rn, S:$rm, AArch64Base_CCMPNVX_nzcvAsInt8:$nzcv );
2207222072

2207322073
field bits<32> Inst;
2207422074

0 commit comments

Comments
 (0)