diff options
author | lloyd <[email protected]> | 2006-08-13 14:13:44 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-08-13 14:13:44 +0000 |
commit | 4a6516c195b932854a4def113e832bd292fe3785 (patch) | |
tree | de6d95856fe939f28ac96e87f7ff47f98897dbdf /modules/alg_ia32/asm_macr.h | |
parent | e08628827ae27dc29fcaa4465849198168b2e9af (diff) |
Clean up the macros, add comment headers, add a couple of helper macros
for spilling/restoring registers.
Reorder some instructions for slightly better scheduling across rounds
Diffstat (limited to 'modules/alg_ia32/asm_macr.h')
-rw-r--r-- | modules/alg_ia32/asm_macr.h | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/modules/alg_ia32/asm_macr.h b/modules/alg_ia32/asm_macr.h index 582184080..a4409a211 100644 --- a/modules/alg_ia32/asm_macr.h +++ b/modules/alg_ia32/asm_macr.h @@ -6,6 +6,9 @@ #ifndef BOTAN_EXT_ASM_MACROS_H__ #define BOTAN_EXT_ASM_MACROS_H__ +/************************************************* +* General/Global Macros * +*************************************************/ #define ALIGN .p2align 4,,15 #define START_LISTING(FILENAME) \ @@ -13,13 +16,22 @@ .text; \ .p2align 4,,15; -#define FUNCTION(func_name) \ - .align 8; \ - ALIGN; \ - .global func_name; \ - .type func_name,@function; \ +/************************************************* +* Function Definitions * +*************************************************/ +#define START_FUNCTION(func_name) \ + .align 8; \ + ALIGN; \ + .global func_name; \ + .type func_name,@function; \ func_name: +#define END_FUNCTION(func_name) \ + ret + +/************************************************* +* Loop Control * +*************************************************/ #define START_LOOP(LABEL) \ ALIGN; \ LABEL##_LOOP: @@ -28,6 +40,9 @@ func_name: cmpl NUM, REG; \ jne LABEL##_LOOP +/************************************************* +* Register Names * +*************************************************/ #define EAX %eax #define EBX %ebx #define ECX %ecx @@ -37,11 +52,9 @@ func_name: #define ESI %esi #define ESP %esp -#define IMM(VAL) $VAL - -#define PUSH(REG) pushl REG -#define POP(REG) popl REG - +/************************************************* +* Memory Access Operations * +*************************************************/ #define ARRAY1(REG, NUM) NUM(REG) #define ARRAY4(REG, NUM) 4*NUM(REG) #define ARRAY4_INDIRECT(BASE, OFFSET, NUM) 4*NUM(BASE,OFFSET,4) @@ -50,6 +63,26 @@ func_name: #define ASSIGN(TO, FROM) movl FROM, TO #define ASSIGN_BYTE(TO, FROM) movzbl FROM, TO +#define PUSH(REG) pushl REG +#define POP(REG) popl REG + +#define SPILL_REGS() \ + PUSH(EBP) ; \ + PUSH(EDI) ; \ + PUSH(ESI) ; \ + PUSH(EBX) + +#define RESTORE_REGS() \ + POP(EBX) ; \ + POP(ESI) ; \ + POP(EDI) ; \ + POP(EBP) + +/************************************************* +* ALU Operations * +*************************************************/ +#define IMM(VAL) $VAL + #define ADD(TO, FROM) addl FROM, TO #define ADD_IMM(TO, NUM) addl IMM(NUM), TO #define SUB_IMM(TO, NUM) subl IMM(NUM), TO |