From f09280141f18fbe8cef0ed576cf932e12e315666 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 17 Sep 2018 22:57:10 -0700 Subject: 4548: start of a compiler for a new experimental low-level language --- transect/compiler6 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 transect/compiler6 (limited to 'transect/compiler6') diff --git a/transect/compiler6 b/transect/compiler6 new file mode 100644 index 00000000..48a7030f --- /dev/null +++ b/transect/compiler6 @@ -0,0 +1,36 @@ +== Goal + +A memory-safe language with a simple translator to x86 that can be feasibly written in x86. + +== Definitions of terms + +Memory-safe: it should be impossible to: + a) create a pointer out of arbitrary data, or + b) to access heap memory after it's been freed. + +Simple: do all the work in a 2-pass translator: + Pass 1: check each instruction's types in isolation. + Pass 2: emit code for each instruction in isolation. + +== types + +int +char +(address _) +(array _ n) +(ref _) + +addresses can't be saved to stack or global, + or included in compound types + or used across a call (to eliminate possibility of free) + + : (address T) <- advance : (array T), : (index T) + +arrays require a size +(ref array _) may not include a size + +== open questions +Is argv an address? +Global variables are easiest to map to addresses. +Ideally we'd represent 'indirect' as a '*' and we could just count to make +sure that an instruction never has more than one '*'. -- cgit 1.4.1-2-gfad0