Radicalc  Check-in [bbec39aeac]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:intrinsic stubs in seperate file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:bbec39aeac097a9178962d77d6fd6b64ecc5120f00e5c0745f8e3f0310e33642
User & Date: athaudia 2017-08-01 16:21:31
Context
2017-08-01
16:47
linking external functions check-in: e8c0955585 user: athaudia tags: trunk
16:21
intrinsic stubs in seperate file check-in: bbec39aeac user: athaudia tags: trunk
14:18
added intrinsincs check-in: 863a252f75 user: athaudia tags: trunk
Changes

Added src/intrinsics.rcs.























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fun add(a:i8,  b:i8):i8   stub
fun add(a:i16, b:i16):i16 stub
fun add(a:i32, b:i32):i32 stub
fun add(a:i64, b:i64):i64 stub
fun add(a:u8,  b:u8): u8  stub
fun add(a:u16, b:u16):u16 stub
fun add(a:u32, b:u32):u32 stub
fun add(a:u64, b:u64):u64 stub

fun sub(a:i8,  b:i8):i8   stub
fun sub(a:i16, b:i16):i16 stub
fun sub(a:i32, b:i32):i32 stub
fun sub(a:i64, b:i64):i64 stub
fun sub(a:u8,  b:u8): u8  stub
fun sub(a:u16, b:u16):u16 stub
fun sub(a:u32, b:u32):u32 stub
fun sub(a:u64, b:u64):u64 stub

fun mul(a:i8,  b:i8):i8   stub
fun mul(a:i16, b:i16):i16 stub
fun mul(a:i32, b:i32):i32 stub
fun mul(a:i64, b:i64):i64 stub
fun mul(a:u8,  b:u8): u8  stub
fun mul(a:u16, b:u16):u16 stub
fun mul(a:u32, b:u32):u32 stub
fun mul(a:u64, b:u64):u64 stub

fun div(a:i8,  b:i8):i8   stub
fun div(a:i16, b:i16):i16 stub
fun div(a:i32, b:i32):i32 stub
fun div(a:i64, b:i64):i64 stub
fun div(a:u8,  b:u8): u8  stub
fun div(a:u16, b:u16):u16 stub
fun div(a:u32, b:u32):u32 stub
fun div(a:u64, b:u64):u64 stub

fun is_less(a:i8,  b:i8): bool stub
fun is_less(a:i16, b:i16):bool stub
fun is_less(a:i32, b:i32):bool stub
fun is_less(a:i64, b:i64):bool stub
fun is_less(a:u8,  b:u8): bool stub
fun is_less(a:u16, b:u16):bool stub
fun is_less(a:u32, b:u32):bool stub
fun is_less(a:u64, b:u64):bool stub

fun is_less_or_eq(a:i8,  b:i8): bool stub
fun is_less_or_eq(a:i16, b:i16):bool stub
fun is_less_or_eq(a:i32, b:i32):bool stub
fun is_less_or_eq(a:i64, b:i64):bool stub
fun is_less_or_eq(a:u8,  b:u8): bool stub
fun is_less_or_eq(a:u16, b:u16):bool stub
fun is_less_or_eq(a:u32, b:u32):bool stub
fun is_less_or_eq(a:u64, b:u64):bool stub

fun is_greater(a:i8,  b:i8): bool stub
fun is_greater(a:i16, b:i16):bool stub
fun is_greater(a:i32, b:i32):bool stub
fun is_greater(a:i64, b:i64):bool stub
fun is_greater(a:u8,  b:u8): bool stub
fun is_greater(a:u16, b:u16):bool stub
fun is_greater(a:u32, b:u32):bool stub
fun is_greater(a:u64, b:u64):bool stub

fun is_greater_or_eq(a:i8,  b:i8): bool stub
fun is_greater_or_eq(a:i16, b:i16):bool stub
fun is_greater_or_eq(a:i32, b:i32):bool stub
fun is_greater_or_eq(a:i64, b:i64):bool stub
fun is_greater_or_eq(a:u8,  b:u8): bool stub
fun is_greater_or_eq(a:u16, b:u16):bool stub
fun is_greater_or_eq(a:u32, b:u32):bool stub
fun is_greater_or_eq(a:u64, b:u64):bool stub

fun is_eq(a:i8,   b:i8):  bool stub
fun is_eq(a:i16,  b:i16): bool stub
fun is_eq(a:i32,  b:i32): bool stub
fun is_eq(a:i64,  b:i64): bool stub
fun is_eq(a:u8,   b:u8):  bool stub
fun is_eq(a:u16,  b:u16): bool stub
fun is_eq(a:u32,  b:u32): bool stub
fun is_eq(a:u64,  b:u64): bool stub
fun is_eq(a:bool, b:bool):bool stub

fun is_not_eq(a:i8,   b:i8):  bool stub
fun is_not_eq(a:i16,  b:i16): bool stub
fun is_not_eq(a:i32,  b:i32): bool stub
fun is_not_eq(a:i64,  b:i64): bool stub
fun is_not_eq(a:u8,   b:u8):  bool stub
fun is_not_eq(a:u16,  b:u16): bool stub
fun is_not_eq(a:u32,  b:u32): bool stub
fun is_not_eq(a:u64,  b:u64): bool stub
fun is_not_eq(a:bool, b:bool):bool stub

Changes to src/radicalc.js.

8
9
10
11
12
13
14

15
16
17
18
19
20
21
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
	console.log("error: " + str);
	process.exit(1);
}

var p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart);

var src = fs.readFileSync("test.rcs", "utf8");

p.feed(src);

if(p.results == 0) {
	console.log("no parse found");
	process.exit(1);
}
else if(p.results > 1) {
................................................................................

llvm.initIntrinsics(dataTypes);
var out = fs.createWriteStream("tmp.ll");
llvm.outFunctions(out, funs);
//llvm.outFunctions(process.stdout, funs);
out.end();

exec('opt -O3 tmp.ll -S -o tmp.s && llc tmp.s -o tmp.o -filetype=obj && lld-link tmp.o /entry:main__i32 /subsystem:console && test2.bat', (error, stdout, stderr) => {
  if (error) {
  	console.error(`exec error: ${error}`);
  	return;
  }
  console.log(stdout);
});

/* todo:
 - unsigned intrinsics
 - figure out how to link against standard functions
 - strings?
*/







>







 







|












8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
	console.log("error: " + str);
	process.exit(1);
}

var p = new nearley.Parser(grammar.ParserRules, grammar.ParserStart);

var src = fs.readFileSync("test.rcs", "utf8");
p.feed(fs.readFileSync("intrinsics.rcs", "utf8"));
p.feed(src);

if(p.results == 0) {
	console.log("no parse found");
	process.exit(1);
}
else if(p.results > 1) {
................................................................................

llvm.initIntrinsics(dataTypes);
var out = fs.createWriteStream("tmp.ll");
llvm.outFunctions(out, funs);
//llvm.outFunctions(process.stdout, funs);
out.end();

exec('opt -O3 tmp.ll -S -o tmp.s && llc tmp.s -o tmp.o -filetype=obj && lld-link tmp.o "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.14393.0\\ucrt\\x64\\ucrt.lib" /entry:main__i32 /subsystem:console && test2.bat', (error, stdout, stderr) => {
  if (error) {
  	console.error(`exec error: ${error}`);
  	return;
  }
  console.log(stdout);
});

/* todo:
 - unsigned intrinsics
 - figure out how to link against standard functions
 - strings?
*/

Changes to src/test.rcs.

1
2
3
4
5
6
7
8
9
10
11
12
13
fun mul(a:i32, b:i32):i32 stub
fun add(a:i32, b:i32):i32 stub
fun is_less_or_eq(a:i32, b:i32):bool stub
fun print(a:i32) stub


fun factorial(n:i32):i32
	var result = 1
	var i = 1
	while i <= n
		result = result * i
		i = i + 1
	end
<
<
<
<
<
<













1
2
3
4
5
6
7






fun factorial(n:i32):i32
	var result = 1
	var i = 1
	while i <= n
		result = result * i
		i = i + 1
	end