tangled
alpha
login
or
join now
eldridge.cam
/
trilogy
1
fork
atom
Actually just three programming languages in a trenchcoat
1
fork
atom
overview
issues
pulls
pipelines
update inkwell
eldridge.cam
4 months ago
c03425e3
0f93ae22
+58
-98
5 changed files
expand all
collapse all
unified
split
Cargo.lock
trilogy-llvm
Cargo.toml
src
bare.rs
call.rs
codegen
cleanup.rs
+9
-36
Cargo.lock
···
270
270
]
271
271
272
272
[[package]]
273
273
-
name = "either"
274
274
-
version = "1.15.0"
275
275
-
source = "registry+https://github.com/rust-lang/crates.io-index"
276
276
-
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
277
277
-
278
278
-
[[package]]
279
273
name = "env_logger"
280
274
version = "0.10.2"
281
275
source = "registry+https://github.com/rust-lang/crates.io-index"
···
685
679
686
680
[[package]]
687
681
name = "inkwell"
688
688
-
version = "0.6.0"
682
682
+
version = "0.7.1"
689
683
source = "registry+https://github.com/rust-lang/crates.io-index"
690
690
-
checksum = "e67349bd7578d4afebbe15eaa642a80b884e8623db74b1716611b131feb1deef"
684
684
+
checksum = "39457e8611219cf690f862a470575f5c06862910d03ea3c3b187ad7abc44b4e2"
691
685
dependencies = [
692
692
-
"either",
693
686
"inkwell_internals",
694
687
"libc",
695
688
"llvm-sys",
696
689
"once_cell",
697
697
-
"thiserror 1.0.69",
690
690
+
"thiserror",
698
691
]
699
692
700
693
[[package]]
701
694
name = "inkwell_internals"
702
702
-
version = "0.11.0"
695
695
+
version = "0.12.0"
703
696
source = "registry+https://github.com/rust-lang/crates.io-index"
704
704
-
checksum = "f365c8de536236cfdebd0ba2130de22acefed18b1fb99c32783b3840aec5fb46"
697
697
+
checksum = "ad9a7dd586b00f2b20e0b9ae3c6faa351fbfd56d15d63bbce35b13bece682eda"
705
698
dependencies = [
706
699
"proc-macro2",
707
700
"quote",
···
1007
1000
"rustc-hash",
1008
1001
"rustls",
1009
1002
"socket2",
1010
1010
-
"thiserror 2.0.16",
1003
1003
+
"thiserror",
1011
1004
"tokio",
1012
1005
"tracing",
1013
1006
"web-time",
···
1028
1021
"rustls",
1029
1022
"rustls-pki-types",
1030
1023
"slab",
1031
1031
-
"thiserror 2.0.16",
1024
1024
+
"thiserror",
1032
1025
"tinyvec",
1033
1026
"tracing",
1034
1027
"web-time",
···
1045
1038
"once_cell",
1046
1039
"socket2",
1047
1040
"tracing",
1048
1048
-
"windows-sys 0.52.0",
1041
1041
+
"windows-sys 0.59.0",
1049
1042
]
1050
1043
1051
1044
[[package]]
···
1450
1443
1451
1444
[[package]]
1452
1445
name = "thiserror"
1453
1453
-
version = "1.0.69"
1454
1454
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1455
1455
-
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
1456
1456
-
dependencies = [
1457
1457
-
"thiserror-impl 1.0.69",
1458
1458
-
]
1459
1459
-
1460
1460
-
[[package]]
1461
1461
-
name = "thiserror"
1462
1446
version = "2.0.16"
1463
1447
source = "registry+https://github.com/rust-lang/crates.io-index"
1464
1448
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
1465
1449
dependencies = [
1466
1466
-
"thiserror-impl 2.0.16",
1467
1467
-
]
1468
1468
-
1469
1469
-
[[package]]
1470
1470
-
name = "thiserror-impl"
1471
1471
-
version = "1.0.69"
1472
1472
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1473
1473
-
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
1474
1474
-
dependencies = [
1475
1475
-
"proc-macro2",
1476
1476
-
"quote",
1477
1477
-
"syn",
1450
1450
+
"thiserror-impl",
1478
1451
]
1479
1452
1480
1453
[[package]]
+1
-1
trilogy-llvm/Cargo.toml
···
5
5
6
6
[dependencies]
7
7
bitvec = "1.0.1"
8
8
-
inkwell = { version = "0.6.0", features = ["llvm18-1"] }
8
8
+
inkwell = { version = "0.7.1", features = ["llvm18-1"] }
9
9
log = "0.4.27"
10
10
num = "0.4.3"
11
11
source-span = "2.7.0"
+41
-45
trilogy-llvm/src/bare.rs
···
3
3
use inkwell::builder::Builder;
4
4
use inkwell::module::Linkage;
5
5
use inkwell::types::FunctionType;
6
6
-
use inkwell::values::{BasicValue, FunctionValue, InstructionValue, IntValue, PointerValue};
6
6
+
use inkwell::values::{FunctionValue, InstructionValue, IntValue, PointerValue};
7
7
8
8
impl<'ctx> Codegen<'ctx> {
9
9
/// Bare functions do not satisfy any particular calling convention, and are intended
···
55
55
.build_call(f, &[value.into()], name)
56
56
.unwrap()
57
57
.try_as_basic_value()
58
58
-
.unwrap_left()
58
58
+
.unwrap_basic()
59
59
.into_int_value()
60
60
}
61
61
···
75
75
.build_call(f, &[value.into()], name)
76
76
.unwrap()
77
77
.try_as_basic_value()
78
78
-
.unwrap_left()
78
78
+
.unwrap_basic()
79
79
.into_int_value()
80
80
}
81
81
···
108
108
)
109
109
.unwrap()
110
110
.try_as_basic_value()
111
111
-
.unwrap_left()
111
111
+
.unwrap_basic()
112
112
.into_pointer_value()
113
113
}
114
114
···
134
134
.build_call(f, &[out.into(), lhs.into(), rhs.into()], name)
135
135
.unwrap()
136
136
.try_as_basic_value()
137
137
-
.unwrap_left()
137
137
+
.unwrap_basic()
138
138
.into_int_value()
139
139
}
140
140
···
160
160
.build_call(f, &[out.into(), lhs.into(), rhs.into()], name)
161
161
.unwrap()
162
162
.try_as_basic_value()
163
163
-
.unwrap_left()
163
163
+
.unwrap_basic()
164
164
.into_int_value()
165
165
}
166
166
···
230
230
)
231
231
.unwrap()
232
232
.try_as_basic_value()
233
233
-
.unwrap_left()
233
233
+
.unwrap_basic()
234
234
.into_pointer_value()
235
235
}
236
236
···
255
255
.build_call(f, &[value.into(), lhs.into(), rhs.into()], "")
256
256
.unwrap()
257
257
.try_as_basic_value()
258
258
-
.unwrap_left()
258
258
+
.unwrap_basic()
259
259
.into_pointer_value()
260
260
}
261
261
···
275
275
.build_call(f, &[t.into()], name)
276
276
.unwrap()
277
277
.try_as_basic_value()
278
278
-
.unwrap_left()
278
278
+
.unwrap_basic()
279
279
.into_pointer_value()
280
280
}
281
281
···
332
332
.build_call(f, &[value.into(), tag.into(), val.into()], "")
333
333
.unwrap()
334
334
.try_as_basic_value()
335
335
-
.unwrap_left()
335
335
+
.unwrap_basic()
336
336
.into_pointer_value()
337
337
}
338
338
···
357
357
.build_call(f, &[value.into(), len.into(), string.into()], "")
358
358
.unwrap()
359
359
.try_as_basic_value()
360
360
-
.unwrap_left()
360
360
+
.unwrap_basic()
361
361
.into_pointer_value()
362
362
}
363
363
···
405
405
)
406
406
.unwrap()
407
407
.try_as_basic_value()
408
408
-
.unwrap_left()
408
408
+
.unwrap_basic()
409
409
.into_pointer_value()
410
410
}
411
411
···
434
434
.build_call(f, &[t.into()], name)
435
435
.unwrap()
436
436
.try_as_basic_value()
437
437
-
.unwrap_left()
437
437
+
.unwrap_basic()
438
438
.into_pointer_value()
439
439
}
440
440
···
454
454
.build_call(f, &[value.into()], name)
455
455
.unwrap()
456
456
.try_as_basic_value()
457
457
-
.unwrap_left()
457
457
+
.unwrap_basic()
458
458
.into_int_value()
459
459
}
460
460
···
610
610
)
611
611
.unwrap()
612
612
.try_as_basic_value()
613
613
-
.unwrap_left()
613
613
+
.unwrap_basic()
614
614
.into_pointer_value()
615
615
}
616
616
···
630
630
.build_call(f, &[t.into()], name)
631
631
.unwrap()
632
632
.try_as_basic_value()
633
633
-
.unwrap_left()
633
633
+
.unwrap_basic()
634
634
.into_pointer_value()
635
635
}
636
636
···
646
646
.build_call(f, &[value.into()], name)
647
647
.unwrap()
648
648
.try_as_basic_value()
649
649
-
.unwrap_left()
649
649
+
.unwrap_basic()
650
650
.into_int_value()
651
651
}
652
652
···
722
722
.build_call(f, &[set.into(), value.into()], name)
723
723
.unwrap()
724
724
.try_as_basic_value()
725
725
-
.unwrap_left()
725
725
+
.unwrap_basic()
726
726
.into_int_value()
727
727
}
728
728
···
753
753
)
754
754
.unwrap()
755
755
.try_as_basic_value()
756
756
-
.unwrap_left()
756
756
+
.unwrap_basic()
757
757
.into_pointer_value()
758
758
}
759
759
···
773
773
.build_call(f, &[t.into()], name)
774
774
.unwrap()
775
775
.try_as_basic_value()
776
776
-
.unwrap_left()
776
776
+
.unwrap_basic()
777
777
.into_pointer_value()
778
778
}
779
779
···
793
793
.build_call(f, &[value.into()], name)
794
794
.unwrap()
795
795
.try_as_basic_value()
796
796
-
.unwrap_left()
796
796
+
.unwrap_basic()
797
797
.into_int_value()
798
798
}
799
799
···
879
879
.build_call(f, &[record.into(), key.into()], name)
880
880
.unwrap()
881
881
.try_as_basic_value()
882
882
-
.unwrap_left()
882
882
+
.unwrap_basic()
883
883
.into_int_value()
884
884
}
885
885
···
903
903
.build_call(f, &[record.into(), key.into()], name)
904
904
.unwrap()
905
905
.try_as_basic_value()
906
906
-
.unwrap_left()
906
906
+
.unwrap_basic()
907
907
.into_int_value()
908
908
}
909
909
···
946
946
.build_call(f, &[value.into()], name)
947
947
.unwrap()
948
948
.try_as_basic_value()
949
949
-
.unwrap_left()
949
949
+
.unwrap_basic()
950
950
.into_pointer_value()
951
951
}
952
952
···
970
970
.build_call(f, &[target.into(), callable.into()], name)
971
971
.unwrap()
972
972
.try_as_basic_value()
973
973
-
.unwrap_left()
973
973
+
.unwrap_basic()
974
974
.into_pointer_value()
975
975
}
976
976
···
1169
1169
)
1170
1170
.unwrap()
1171
1171
.try_as_basic_value()
1172
1172
-
.unwrap_left()
1172
1172
+
.unwrap_basic()
1173
1173
.into_pointer_value()
1174
1174
}
1175
1175
···
1205
1205
)
1206
1206
.unwrap()
1207
1207
.try_as_basic_value()
1208
1208
-
.unwrap_left()
1208
1208
+
.unwrap_basic()
1209
1209
.into_pointer_value()
1210
1210
}
1211
1211
···
1227
1227
.build_call(f, &[value.into()], name)
1228
1228
.unwrap()
1229
1229
.try_as_basic_value()
1230
1230
-
.unwrap_left()
1230
1230
+
.unwrap_basic()
1231
1231
.into_pointer_value()
1232
1232
}
1233
1233
···
1249
1249
.build_call(f, &[value.into()], name)
1250
1250
.unwrap()
1251
1251
.try_as_basic_value()
1252
1252
-
.unwrap_left()
1252
1252
+
.unwrap_basic()
1253
1253
.into_pointer_value()
1254
1254
}
1255
1255
···
1273
1273
.build_call(f, &[lhs.into(), rhs.into()], name)
1274
1274
.unwrap()
1275
1275
.try_as_basic_value()
1276
1276
-
.unwrap_left()
1276
1276
+
.unwrap_basic()
1277
1277
.into_int_value()
1278
1278
}
1279
1279
···
1349
1349
.build_call(f, &[value.into()], "")
1350
1350
.unwrap()
1351
1351
.try_as_basic_value()
1352
1352
-
.either(|l| l.as_instruction_value(), Some)
1353
1353
-
.unwrap()
1352
1352
+
.unwrap_instruction()
1354
1353
}
1355
1354
1356
1355
pub(crate) fn trilogy_callable_init_proc(
···
1525
1524
.build_call(f, &[t.into()], "")
1526
1525
.unwrap()
1527
1526
.try_as_basic_value()
1528
1528
-
.either(|l| l.as_instruction_value(), Some)
1529
1529
-
.unwrap();
1527
1527
+
.unwrap_instruction();
1530
1528
self.end_continuation_point_as_clean(call);
1531
1529
self.builder.build_unreachable().unwrap();
1532
1530
NeverValue
···
1571
1569
.build_call(f, &[t.into()], "")
1572
1570
.unwrap()
1573
1571
.try_as_basic_value()
1574
1574
-
.unwrap_left()
1572
1572
+
.unwrap_basic()
1575
1573
.into_pointer_value()
1576
1574
}
1577
1575
···
1591
1589
.build_call(f, &[t.into()], name)
1592
1590
.unwrap()
1593
1591
.try_as_basic_value()
1594
1594
-
.unwrap_left()
1592
1592
+
.unwrap_basic()
1595
1593
.into_pointer_value()
1596
1594
}
1597
1595
···
1625
1623
.build_call(f, &[pointer.into(), pointee.into()], name)
1626
1624
.unwrap()
1627
1625
.try_as_basic_value()
1628
1628
-
.unwrap_left()
1626
1626
+
.unwrap_basic()
1629
1627
.into_pointer_value()
1630
1628
}
1631
1629
···
1812
1810
)
1813
1811
.unwrap()
1814
1812
.try_as_basic_value()
1815
1815
-
.unwrap_left()
1813
1813
+
.unwrap_basic()
1816
1814
.into_pointer_value()
1817
1815
}
1818
1816
···
1829
1827
.build_call(f, &[effect.into()], "")
1830
1828
.unwrap()
1831
1829
.try_as_basic_value()
1832
1832
-
.either(|l| l.as_instruction_value(), Some)
1833
1833
-
.unwrap();
1830
1830
+
.unwrap_instruction();
1834
1831
self.end_continuation_point_as_clean(call);
1835
1832
self.builder.build_unreachable().unwrap();
1836
1833
NeverValue
···
1846
1843
.build_call(f, &[], "")
1847
1844
.unwrap()
1848
1845
.try_as_basic_value()
1849
1849
-
.either(|l| l.as_instruction_value(), Some)
1850
1850
-
.unwrap();
1846
1846
+
.unwrap_instruction();
1851
1847
self.end_continuation_point_as_clean(call);
1852
1848
self.builder.build_unreachable().unwrap();
1853
1849
NeverValue
···
1869
1865
.build_call(f, &[value.into()], name)
1870
1866
.unwrap()
1871
1867
.try_as_basic_value()
1872
1872
-
.unwrap_left()
1868
1868
+
.unwrap_basic()
1873
1869
.into_pointer_value()
1874
1870
}
1875
1871
···
1893
1889
.build_call(f, &[target.into(), module_data.into()], name)
1894
1890
.unwrap()
1895
1891
.try_as_basic_value()
1896
1896
-
.unwrap_left()
1892
1892
+
.unwrap_basic()
1897
1893
.into_pointer_value()
1898
1894
}
1899
1895
···
1923
1919
)
1924
1920
.unwrap()
1925
1921
.try_as_basic_value()
1926
1926
-
.unwrap_left()
1922
1922
+
.unwrap_basic()
1927
1923
.into_pointer_value()
1928
1924
}
1929
1925
+6
-14
trilogy-llvm/src/call.rs
···
4
4
use inkwell::llvm_sys::LLVMCallConv;
5
5
use inkwell::module::Linkage;
6
6
use inkwell::values::{
7
7
-
BasicMetadataValueEnum, BasicValue, FunctionValue, InstructionValue, IntValue,
8
8
-
LLVMTailCallKind, PointerValue,
7
7
+
BasicMetadataValueEnum, FunctionValue, InstructionValue, IntValue, LLVMTailCallKind,
8
8
+
PointerValue,
9
9
};
10
10
use inkwell::{AddressSpace, IntPredicate};
11
11
···
421
421
.unwrap();
422
422
call.set_call_convention(LLVMCallConv::LLVMFastCallConv as u32);
423
423
call.set_tail_call_kind(LLVMTailCallKind::LLVMTailCallKindTail);
424
424
-
let call = call
425
425
-
.try_as_basic_value()
426
426
-
.either(|l| l.as_instruction_value(), Some)
427
427
-
.unwrap();
424
424
+
let call = call.try_as_basic_value().unwrap_instruction();
428
425
self.end_continuation_point_as_clean(call);
429
426
self.builder.build_return(None).unwrap();
430
427
}
···
484
481
args.extend_from_slice(arguments);
485
482
let call = self.builder.build_call(procedure, &args, "").unwrap();
486
483
call.set_call_convention(LLVMCallConv::LLVMFastCallConv as u32);
487
487
-
call.try_as_basic_value()
488
488
-
.either(|l| l.as_instruction_value(), Some)
489
489
-
.unwrap()
484
484
+
call.try_as_basic_value().unwrap_instruction()
490
485
}
491
486
492
487
/// A core function is much like an internal function, but is defined in C
···
500
495
let mut args = vec![target.into()];
501
496
args.extend_from_slice(arguments);
502
497
let call = self.builder.build_call(procedure, &args, "").unwrap();
503
503
-
call.try_as_basic_value()
504
504
-
.either(|l| l.as_instruction_value(), Some)
505
505
-
.unwrap()
498
498
+
call.try_as_basic_value().unwrap_instruction()
506
499
}
507
500
508
501
/// Calls the contextual `yield` continuation.
···
684
677
.build_indirect_call(self.continuation_type(1), continue_continuation, args, name)
685
678
.unwrap()
686
679
.try_as_basic_value()
687
687
-
.either(|l| l.as_instruction_value(), Some)
688
688
-
.unwrap();
680
680
+
.unwrap_instruction();
689
681
self.builder.build_return(None).unwrap();
690
682
self.end_continuation_point_as_clean(call);
691
683
}
+1
-2
trilogy-llvm/src/codegen/cleanup.rs
···
140
140
.build_call(do_nothing, &[], "noop")
141
141
.unwrap()
142
142
.try_as_basic_value()
143
143
-
.either(|l| l.as_instruction_value(), Some)
144
144
-
.unwrap();
143
143
+
.unwrap_instruction();
145
144
cp.shadow_root()
146
145
.unclosed
147
146
.borrow_mut()