From 3cf03158599472b1f6713192d9fa2b120f9f209b Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 7 Mar 2020 17:32:39 -0800 Subject: 6094 - new 'compute-offset' instruction If indexing into a type with power-of-2-sized elements we can access them in one instruction: x/reg1: (addr int) <- index A/reg2: (addr array int), idx/reg3: int This translates to a single instruction because x86 instructions support an addressing mode with left-shifts. For non-powers-of-2, however, we need a multiply. To keep things type-safe, it is performed like this: x/reg1: (offset T) <- compute-offset A: (addr array T), idx: int y/reg2: (addr T) <- index A, x An offset is just an int that is guaranteed to be a multiple of size-of(T). Offsets can only be used in index instructions, and the types will eventually be required to line up. In the process, I have to expand Input-size because mu.subx is growing big. --- mu_summary | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'mu_summary') diff --git a/mu_summary b/mu_summary index 179aa11f..e4e82905 100644 --- a/mu_summary +++ b/mu_summary @@ -197,9 +197,14 @@ Similarly, conditional loops: ## Array operations - var/reg: int <- length var: (addr array T) - var/reg: (addr T) <- index var: (addr array T), idx: int - var/reg: (addr T) <- index var: (addr array T), n + var/reg: int <- length arr/reg: (addr array T) + var/reg: (addr T) <- index arr/reg: (addr array T), idx/reg: int + var/reg: (addr T) <- index arr/reg: (addr array T), n + + var/reg: (offset T) <- compute-offset arr: (addr array T), idx/reg: int # arr can be in reg or mem + var/reg: (offset T) <- compute-offset arr: (addr array T), n # arr can be in reg or mem + var: (offset T) <- compute-offset arr: (addr array T), n # arr can be in reg or mem + var/reg: (addr T) <- index arr/reg: (addr array T), idx/reg: (offset T) ## User-defined types -- cgit 1.4.1-2-gfad0