Skip to content

Commit 0ffa2ee

Browse files
chathhornDwight Guth
authored andcommitted
Minor refactor.
1 parent 65beda3 commit 0ffa2ee

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

semantics/common/alignment.k

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module ALIGNMENT-SYNTAX
22
imports SYMLOC-SORTS
33
imports INT-SYNTAX
44

5-
syntax Int ::= getAlign(SymLoc) [function]
5+
syntax Int ::= getAlign(SymLoc) [function, withConfig]
66
syntax Int ::= getNativeAlign(address: Int, max: Int) [function]
77
endmodule
88

@@ -14,16 +14,24 @@ module ALIGNMENT
1414
imports C-SETTINGS-SYNTAX
1515

1616
rule getAlign(NullPointer) => cfg:alignofMalloc
17-
rule getAlign(Loc::SymLoc) => getAlign'(base(Loc), offset(Loc)) [owise]
18-
syntax Int ::= "getAlign'" "(" SymBase "," Int ")" [function, withConfig]
17+
rule getAlign(Loc::SymLoc) => getAlign'(base(Loc), offset(Loc))
18+
requires notBool isLinkerLoc(Loc)
19+
rule [[ getAlign(Loc::SymLoc => resolveLinking(Loc, Linkings)) ]]
20+
<linkings> Linkings::Map </linkings>
21+
requires isLinkerLoc(Loc) andBool base(Loc) in_keys(Linkings)
22+
rule getAlign(Loc::SymLoc) => getAlign'(base(Loc), offset(Loc))
23+
[owise]
24+
25+
syntax Int ::= "getAlign'" "(" SymBase "," Int ")" [function]
26+
rule getAlign'(obj(... align: Align::Int)::DirectBase, I::Int) => getNativeAlign(I, Align)
27+
rule getAlign'(obj(... align: Align::Int)::LinkBase, I::Int) => getNativeAlign(I, Align)
28+
29+
rule getNativeAlign(_, 0) => 0
30+
rule getNativeAlign(Address::Int, Max::Int) => #getNativeAlign(Address %Int Max, Max, 1) [owise]
1931

20-
rule getAlign'(obj(... align: 0)::DirectBase, _) => 0
21-
rule [[ getAlign'((obj(... d: link(_)) #as Base::SymBase => Base'), _) ]]
22-
<linkings>... Base |-> Base'::SymBase ...</linkings>
23-
rule getAlign'(obj(... align: Align::Int)::DirectBase, I::Int) => getNativeAlign(I %Int Align, Align) [owise]
2432
syntax Int ::= #getNativeAlign(Int, Int, Int) [function]
25-
rule getNativeAlign(Address::Int, Max::Int) => #getNativeAlign(Address, Max, 1)
26-
rule #getNativeAlign(Address::Int, Max::Int, Accum::Int) => #getNativeAlign(Address, Max, Accum <<Int 1)
33+
rule #getNativeAlign(Address::Int, Max::Int, Accum::Int)
34+
=> #getNativeAlign(Address, Max, Accum <<Int 1)
2735
requires Address &Int Accum ==Int 0 andBool Accum <Int Max
2836
rule #getNativeAlign(_, Accum::Int, _) => Accum [owise]
2937

0 commit comments

Comments
 (0)