Skip to content

Commit eee17ed

Browse files
authored
fix: name clashes for perspective columns (#868)
Columns defined in perspective can no longer clash with columns of the same name defined in other perspectives and/or the enclosing module. This behaviour was maintained to ensure compatibility with the original corset tool. However, since all components are now generated by go-corset we are no longer constrained in this way.
1 parent 4636b72 commit eee17ed

File tree

70 files changed

+2267
-2724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2267
-2724
lines changed

pkg/corset/compiler/allocation.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ func (r *Register) Name() string {
100100
})
101101
//
102102
for i, source := range r.Sources {
103-
// FIXME: below is used instead of above in order to replicate the original
104-
// Corset tool. Eventually, this behaviour should be deprecated.
105-
names[i] = source.Name.Tail()
103+
names[i] = constructColumnName(source)
106104
}
107105
// Construct register name from list of names
108106
name := constructRegisterName(names)
@@ -112,6 +110,15 @@ func (r *Register) Name() string {
112110
return *r.cached_name
113111
}
114112

113+
// Construct a suitable column name from a given register source. We need to
114+
// include the perspective name here in order to avoid name clashes between
115+
// columns with the same name defined in different columns.
116+
func constructColumnName(source RegisterSource) string {
117+
name := fmt.Sprintf("%s%s", source.Perspective(), source.Name.Tail())
118+
// Normalise name
119+
return strings.ReplaceAll(name, "/", "")
120+
}
121+
115122
// A simple algorithm for joining names together.
116123
func constructRegisterName(names []string) string {
117124
str := ""

pkg/test/valid_corset_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,10 +1302,6 @@ func TestSlow_Mmio(t *testing.T) {
13021302
// Check(t, true, "rom")
13031303
// }
13041304

1305-
func TestSlow_Mmu(t *testing.T) {
1306-
Check(t, true, "mmu")
1307-
}
1308-
13091305
func TestSlow_Gas(t *testing.T) {
13101306
Check(t, true, "gas")
13111307
}

testdata/array_08.accepts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{ "m1.SEL": [], "m1.BYTE_1": [], "m1.BYTE_2": [] }
2-
{ "m1.SEL": [0], "m1.BYTE_1": [0], "m1.BYTE_2": [0] }
3-
{ "m1.SEL": [0], "m1.BYTE_1": [0], "m1.BYTE_2": [1] }
4-
{ "m1.SEL": [0], "m1.BYTE_1": [1], "m1.BYTE_2": [0] }
5-
{ "m1.SEL": [0], "m1.BYTE_1": [1], "m1.BYTE_2": [1] }
6-
{ "m1.SEL": [1], "m1.BYTE_1": [0], "m1.BYTE_2": [0] }
7-
{ "m1.SEL": [1], "m1.BYTE_1": [0], "m1.BYTE_2": [1] }
1+
{ "m1.SEL": [], "m1.testBYTE_1": [], "m1.testBYTE_2": [] }
2+
{ "m1.SEL": [0], "m1.testBYTE_1": [0], "m1.testBYTE_2": [0] }
3+
{ "m1.SEL": [0], "m1.testBYTE_1": [0], "m1.testBYTE_2": [1] }
4+
{ "m1.SEL": [0], "m1.testBYTE_1": [1], "m1.testBYTE_2": [0] }
5+
{ "m1.SEL": [0], "m1.testBYTE_1": [1], "m1.testBYTE_2": [1] }
6+
{ "m1.SEL": [1], "m1.testBYTE_1": [0], "m1.testBYTE_2": [0] }
7+
{ "m1.SEL": [1], "m1.testBYTE_1": [0], "m1.testBYTE_2": [1] }

testdata/array_08.rejects

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{ "m1.SEL": [1], "m1.BYTE_1": [1], "m1.BYTE_2": [0] }
2-
{ "m1.SEL": [1], "m1.BYTE_1": [1], "m1.BYTE_2": [1] }
1+
{ "m1.SEL": [1], "m1.testBYTE_1": [1], "m1.testBYTE_2": [0] }
2+
{ "m1.SEL": [1], "m1.testBYTE_1": [1], "m1.testBYTE_2": [1] }

testdata/exp.accepts.bz2

496 Bytes
Binary file not shown.

testdata/interleave_05.accepts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{ "P": [], "X": [], "Y": [] }
2-
{ "P": [1], "X": [0], "Y": [0] }
3-
{ "P": [1,1], "X": [0,0], "Y": [0,0] }
4-
{ "P": [1,1,1], "X": [0,0,0], "Y": [0,0,0] }
5-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [0,0,0,0] }
1+
{ "P": [], "X": [], "p1Y": [] }
2+
{ "P": [1], "X": [0], "p1Y": [0] }
3+
{ "P": [1,1], "X": [0,0], "p1Y": [0,0] }
4+
{ "P": [1,1,1], "X": [0,0,0], "p1Y": [0,0,0] }
5+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [0,0,0,0] }

testdata/interleave_05.rejects

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{ "P": [1], "X": [1], "Y": [0] }
2-
{ "P": [1], "X": [0], "Y": [1] }
3-
{ "P": [1,1], "X": [0,0], "Y": [0,1] }
4-
{ "P": [1,1], "X": [0,0], "Y": [1,0] }
5-
{ "P": [1,1], "X": [0,1], "Y": [0,0] }
6-
{ "P": [1,1], "X": [1,0], "Y": [0,0] }
1+
{ "P": [1], "X": [1], "p1Y": [0] }
2+
{ "P": [1], "X": [0], "p1Y": [1] }
3+
{ "P": [1,1], "X": [0,0], "p1Y": [0,1] }
4+
{ "P": [1,1], "X": [0,0], "p1Y": [1,0] }
5+
{ "P": [1,1], "X": [0,1], "p1Y": [0,0] }
6+
{ "P": [1,1], "X": [1,0], "p1Y": [0,0] }
77
;;
8-
{ "P": [1,1], "X": [1,0], "Y": [0,1] }
9-
{ "P": [1,1], "X": [0,1], "Y": [0,1] }
10-
{ "P": [1,1], "X": [1,0], "Y": [1,0] }
11-
{ "P": [1,1], "X": [0,1], "Y": [1,0] }
12-
{ "P": [1,1], "X": [1,0], "Y": [0,1] }
13-
{ "P": [1,1], "X": [0,1], "Y": [0,1] }
8+
{ "P": [1,1], "X": [1,0], "p1Y": [0,1] }
9+
{ "P": [1,1], "X": [0,1], "p1Y": [0,1] }
10+
{ "P": [1,1], "X": [1,0], "p1Y": [1,0] }
11+
{ "P": [1,1], "X": [0,1], "p1Y": [1,0] }
12+
{ "P": [1,1], "X": [1,0], "p1Y": [0,1] }
13+
{ "P": [1,1], "X": [0,1], "p1Y": [0,1] }

testdata/interleave_06.accepts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
{ "P": [], "X": [], "Y": [] }
2-
{ "P": [1], "X": [0], "Y": [0] }
3-
{ "P": [1,1], "X": [0,0], "Y": [0,0] }
4-
{ "P": [1,1,1], "X": [0,0,0], "Y": [0,0,0] }
5-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [0,0,0,0] }
6-
{ "P": [1,0,1,1], "X": [0,1,0,0], "Y": [0,0,0,0] }
7-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [0,0,1,0] }
8-
{ "P": [1,0,0,1], "X": [0,1,0,0], "Y": [0,0,1,0] }
9-
{ "P": [0,1,0,1], "X": [1,0,0,0], "Y": [0,0,1,0] }
1+
{ "P": [], "X": [], "p1Y": [] }
2+
{ "P": [1], "X": [0], "p1Y": [0] }
3+
{ "P": [1,1], "X": [0,0], "p1Y": [0,0] }
4+
{ "P": [1,1,1], "X": [0,0,0], "p1Y": [0,0,0] }
5+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [0,0,0,0] }
6+
{ "P": [1,0,1,1], "X": [0,1,0,0], "p1Y": [0,0,0,0] }
7+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [0,0,1,0] }
8+
{ "P": [1,0,0,1], "X": [0,1,0,0], "p1Y": [0,0,1,0] }
9+
{ "P": [0,1,0,1], "X": [1,0,0,0], "p1Y": [0,0,1,0] }
1010
;;
11-
{ "P": [0], "X": [1], "Y": [0] }
12-
{ "P": [0], "X": [0], "Y": [1] }
13-
{ "P": [0,0], "X": [0,0], "Y": [0,1] }
14-
{ "P": [1,0], "X": [0,0], "Y": [0,1] }
15-
{ "P": [0,0], "X": [0,0], "Y": [1,0] }
16-
{ "P": [0,1], "X": [0,0], "Y": [1,0] }
17-
{ "P": [0,0], "X": [0,1], "Y": [0,0] }
18-
{ "P": [1,0], "X": [0,1], "Y": [0,0] }
19-
{ "P": [0,0], "X": [1,0], "Y": [0,0] }
20-
{ "P": [0,1], "X": [1,0], "Y": [0,0] }
11+
{ "P": [0], "X": [1], "p1Y": [0] }
12+
{ "P": [0], "X": [0], "p1Y": [1] }
13+
{ "P": [0,0], "X": [0,0], "p1Y": [0,1] }
14+
{ "P": [1,0], "X": [0,0], "p1Y": [0,1] }
15+
{ "P": [0,0], "X": [0,0], "p1Y": [1,0] }
16+
{ "P": [0,1], "X": [0,0], "p1Y": [1,0] }
17+
{ "P": [0,0], "X": [0,1], "p1Y": [0,0] }
18+
{ "P": [1,0], "X": [0,1], "p1Y": [0,0] }
19+
{ "P": [0,0], "X": [1,0], "p1Y": [0,0] }
20+
{ "P": [0,1], "X": [1,0], "p1Y": [0,0] }
2121
;;
22-
{ "P": [0,0], "X": [1,0], "Y": [0,1] }
23-
{ "P": [0,0], "X": [0,1], "Y": [0,1] }
24-
{ "P": [0,0], "X": [1,0], "Y": [1,0] }
25-
{ "P": [0,0], "X": [0,1], "Y": [1,0] }
26-
{ "P": [0,0], "X": [1,0], "Y": [0,1] }
27-
{ "P": [0,0], "X": [0,1], "Y": [0,1] }
22+
{ "P": [0,0], "X": [1,0], "p1Y": [0,1] }
23+
{ "P": [0,0], "X": [0,1], "p1Y": [0,1] }
24+
{ "P": [0,0], "X": [1,0], "p1Y": [1,0] }
25+
{ "P": [0,0], "X": [0,1], "p1Y": [1,0] }
26+
{ "P": [0,0], "X": [1,0], "p1Y": [0,1] }
27+
{ "P": [0,0], "X": [0,1], "p1Y": [0,1] }

testdata/interleave_06.rejects

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
{ "P": [1], "X": [1], "Y": [0] }
2-
{ "P": [1], "X": [0], "Y": [1] }
3-
{ "P": [1,1], "X": [0,0], "Y": [0,1] }
4-
{ "P": [1,1], "X": [0,0], "Y": [1,0] }
5-
{ "P": [1,1], "X": [0,1], "Y": [0,0] }
6-
{ "P": [1,1], "X": [1,0], "Y": [0,0] }
1+
{ "P": [1], "X": [1], "p1Y": [0] }
2+
{ "P": [1], "X": [0], "p1Y": [1] }
3+
{ "P": [1,1], "X": [0,0], "p1Y": [0,1] }
4+
{ "P": [1,1], "X": [0,0], "p1Y": [1,0] }
5+
{ "P": [1,1], "X": [0,1], "p1Y": [0,0] }
6+
{ "P": [1,1], "X": [1,0], "p1Y": [0,0] }
77
;;
8-
{ "P": [1,1], "X": [1,0], "Y": [0,1] }
9-
{ "P": [1,1], "X": [0,1], "Y": [0,1] }
10-
{ "P": [1,1], "X": [1,0], "Y": [1,0] }
11-
{ "P": [1,1], "X": [0,1], "Y": [1,0] }
12-
{ "P": [1,1], "X": [1,0], "Y": [0,1] }
13-
{ "P": [1,1], "X": [0,1], "Y": [0,1] }
8+
{ "P": [1,1], "X": [1,0], "p1Y": [0,1] }
9+
{ "P": [1,1], "X": [0,1], "p1Y": [0,1] }
10+
{ "P": [1,1], "X": [1,0], "p1Y": [1,0] }
11+
{ "P": [1,1], "X": [0,1], "p1Y": [1,0] }
12+
{ "P": [1,1], "X": [1,0], "p1Y": [0,1] }
13+
{ "P": [1,1], "X": [0,1], "p1Y": [0,1] }
1414
;;
15-
{ "P": [1,1,1,1], "X": [1,0,0,0], "Y": [0,0,0,0] }
16-
{ "P": [1,1,1,1], "X": [0,1,0,0], "Y": [0,0,0,0] }
17-
{ "P": [1,1,1,1], "X": [0,0,1,0], "Y": [0,0,0,0] }
18-
{ "P": [1,1,1,1], "X": [0,0,0,1], "Y": [0,0,0,0] }
19-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [1,0,0,0] }
20-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [0,1,0,0] }
21-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [0,0,1,0] }
22-
{ "P": [1,1,1,1], "X": [0,0,0,0], "Y": [0,0,0,1] }
23-
{ "P": [1,1,1,1], "X": [0,0,0,1], "Y": [1,0,0,0] }
24-
{ "P": [1,1,1,1], "X": [0,0,1,0], "Y": [0,1,0,0] }
25-
{ "P": [1,1,1,1], "X": [0,1,0,0], "Y": [0,0,1,0] }
26-
{ "P": [1,1,1,1], "X": [1,0,0,0], "Y": [0,0,0,1] }
15+
{ "P": [1,1,1,1], "X": [1,0,0,0], "p1Y": [0,0,0,0] }
16+
{ "P": [1,1,1,1], "X": [0,1,0,0], "p1Y": [0,0,0,0] }
17+
{ "P": [1,1,1,1], "X": [0,0,1,0], "p1Y": [0,0,0,0] }
18+
{ "P": [1,1,1,1], "X": [0,0,0,1], "p1Y": [0,0,0,0] }
19+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [1,0,0,0] }
20+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [0,1,0,0] }
21+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [0,0,1,0] }
22+
{ "P": [1,1,1,1], "X": [0,0,0,0], "p1Y": [0,0,0,1] }
23+
{ "P": [1,1,1,1], "X": [0,0,0,1], "p1Y": [1,0,0,0] }
24+
{ "P": [1,1,1,1], "X": [0,0,1,0], "p1Y": [0,1,0,0] }
25+
{ "P": [1,1,1,1], "X": [0,1,0,0], "p1Y": [0,0,1,0] }
26+
{ "P": [1,1,1,1], "X": [1,0,0,0], "p1Y": [0,0,0,1] }
2727
;;
28-
{ "P": [1,0,1,1], "X": [1,0,0,0], "Y": [0,0,0,0] }
29-
{ "P": [1,0,1,1], "X": [0,0,1,0], "Y": [0,0,0,0] }
30-
{ "P": [1,0,1,1], "X": [0,0,0,1], "Y": [0,0,0,0] }
31-
{ "P": [1,0,1,1], "X": [0,0,1,1], "Y": [0,0,0,0] }
32-
{ "P": [1,0,1,1], "X": [1,0,1,0], "Y": [0,0,0,0] }
33-
{ "P": [1,0,1,1], "X": [1,0,1,1], "Y": [0,0,0,0] }
34-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [1,0,0,0] }
35-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [0,1,0,0] }
36-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [1,1,0,0] }
37-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [0,0,0,1] }
38-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [1,0,0,1] }
39-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [0,1,0,1] }
40-
{ "P": [1,1,0,1], "X": [0,0,0,0], "Y": [1,1,0,1] }
28+
{ "P": [1,0,1,1], "X": [1,0,0,0], "p1Y": [0,0,0,0] }
29+
{ "P": [1,0,1,1], "X": [0,0,1,0], "p1Y": [0,0,0,0] }
30+
{ "P": [1,0,1,1], "X": [0,0,0,1], "p1Y": [0,0,0,0] }
31+
{ "P": [1,0,1,1], "X": [0,0,1,1], "p1Y": [0,0,0,0] }
32+
{ "P": [1,0,1,1], "X": [1,0,1,0], "p1Y": [0,0,0,0] }
33+
{ "P": [1,0,1,1], "X": [1,0,1,1], "p1Y": [0,0,0,0] }
34+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [1,0,0,0] }
35+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [0,1,0,0] }
36+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [1,1,0,0] }
37+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [0,0,0,1] }
38+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [1,0,0,1] }
39+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [0,1,0,1] }
40+
{ "P": [1,1,0,1], "X": [0,0,0,0], "p1Y": [1,1,0,1] }

testdata/mmu.accepts.bz2

-2.01 MB
Binary file not shown.

0 commit comments

Comments
 (0)