Skip to content

Commit 9c8d76a

Browse files
authored
Merge pull request #619 from OpenVADL/bugfix/fix-large-constant-lowering-bug
lowering: Fix bug in constant lowering with large constants
2 parents 782c237 + c8411a2 commit 9c8d76a

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

sys/ppc64/ppc64.vadl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,12 @@ instruction set architecture PPC64SFS = {
432432
fxm(3) as SNibble, fxm(2) as SNibble,
433433
fxm(1) as SNibble, fxm(0) as SNibble)
434434

435-
// TODO: remove
436-
constant msrtrap : Bits<64> = 0x8000000000001000
437435
// triggered by the tw and twi instructions if at least one trap condition evaluates to true
438436
exception Trap () = {
439437
SRR0 := PC
440438
SRR1 := (MSR(63..31), 0 as Nibble, MSR(26..22), 0 as Nibble, 1 as Bits<1>, 0 as Bits<1>, MSR(15..0))
441439
PC := 0x0000'0000'0000'0700
442-
MSR := msrtrap
440+
MSR := 0x8000000000001000
443441
}
444442

445443
// triggered when a privileged instruction gets called in an unprivileged processor state

vadl/main/vadl/ast/BehaviorLowering.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,10 +1388,10 @@ public ExpressionNode visit(CastExpr expr) {
13881388
// Shortcut for constant types
13891389
var viamType = getViamType(expr.type());
13901390
if (expr.value.type instanceof ConstantType constType) {
1391-
return new ConstantNode(
1392-
Constant.Value.of(constType.getValue().longValueExact(),
1393-
(DataType) constType.closestTo(viamType))
1394-
.castTo((DataType) viamType));
1391+
return Constant.Value.fromInteger(constType.getValue(),
1392+
(DataType) constType.closestTo(viamType))
1393+
.castTo((DataType) viamType)
1394+
.toNode();
13951395
}
13961396

13971397
// check the different rules and apply them accordingly
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This was a bug before
2+
// https://github.com/OpenVADL/openvadl/issues/616
3+
4+
instruction set architecture ISA = {
5+
register MSR : Bits<64>
6+
7+
exception Trap () = {
8+
MSR := 0x8000000000001000
9+
}
10+
}
11+
12+
13+
// Reported Diagnostics:
14+
//
15+
// No diagnostics were reported, the input was correctly parsed, typechecked and lowered.
16+
//
17+
//
18+
// Part of the class vadl.ast.DiagnosticsTest

0 commit comments

Comments
 (0)