Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Kowalke committed Mar 7, 2014
2 parents 06e99c9 + 7e49b37 commit 9f37c9b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 142 deletions.
167 changes: 38 additions & 129 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ feature.set-default abi : [ default_abi ] ;

actions gas
{
as -o "$(<)" "$(>)"
cpp -x assembler-with-cpp "$(>)" | as -am -o "$(<)"
}

actions armasm
Expand Down Expand Up @@ -105,27 +105,17 @@ rule configure ( properties * )

# ARM
alias asm_context_sources
: asm/make_arm_aapcs_macho_gas.S
asm/jump_arm_aapcs_macho_gas.S
untested.cpp
: <architecture>arm
<target-os>iphone
<toolset>darwin
;

alias asm_context_sources
: asm/make_arm_aapcs_elf_gas.S
asm/jump_arm_aapcs_elf_gas.S
: [ make asm/make_arm_aapcs_elf_gas.o : asm/make_arm_aapcs_elf_gas.S : @gas ]
[ make asm/jump_arm_aapcs_elf_gas.o : asm/jump_arm_aapcs_elf_gas.S : @gas ]
: <architecture>arm
<binary-format>elf
<toolset>gcc
;

alias asm_context_sources
: [ make asm/make_arm_aapcs_elf_gas.o : asm/make_arm_aapcs_elf_gas.S : @gas ]
[ make asm/jump_arm_aapcs_elf_gas.o : asm/jump_arm_aapcs_elf_gas.S : @gas ]
: [ make asm/make_arm_aapcs_macho_gas.o : asm/make_arm_aapcs_macho_gas.S : @gas ]
[ make asm/jump_arm_aapcs_macho_gas.o : asm/jump_arm_aapcs_macho_gas.S : @gas ]
: <architecture>arm
<binary-format>elf
<binary-format>mach-o
;

alias asm_context_sources
Expand All @@ -144,35 +134,21 @@ alias asm_context_sources
<binary-format>elf
;

# POWERPC
# POWERPC_32
alias asm_context_sources
: asm/make_ppc32_sysv_macho_gas.S
asm/jump_ppc32_sysv_macho_gas.S
untested.cpp
: [ make asm/make_ppc32_sysv_elf_gas.o : asm/make_ppc32_sysv_elf_gas.S : @gas ]
[ make asm/jump_ppc32_sysv_elf_gas.o : asm/jump_ppc32_sysv_elf_gas.S : @gas ]
: <address-model>32
<architecture>power
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
<binary-format>elf
;

alias asm_context_sources
: asm/make_ppc32_sysv_macho_gas.S
asm/jump_ppc32_sysv_macho_gas.S
untested.cpp
: [ make asm/make_ppc32_sysv_macho_gas.o : asm/make_ppc32_sysv_macho_gas.S : @gas ]
[ make asm/jump_ppc32_sysv_macho_gas.o : asm/jump_ppc32_sysv_macho_gas.S : @gas ]
: <address-model>32
<architecture>power
<binary-format>mach-o
<target-os>darwin
<toolset>clang
;

alias asm_context_sources
: [ make asm/make_ppc32_sysv_elf_gas.o : asm/make_ppc32_sysv_elf_gas.S : @gas ]
[ make asm/jump_ppc32_sysv_elf_gas.o : asm/jump_ppc32_sysv_elf_gas.S : @gas ]
: <address-model>32
<architecture>power
<binary-format>elf
;

alias asm_context_sources
Expand All @@ -186,34 +162,20 @@ alias asm_context_sources

# POWERPC_64
alias asm_context_sources
: asm/make_ppc64_sysv_macho_gas.S
asm/jump_ppc64_sysv_macho_gas.S
untested.cpp
: [ make asm/make_ppc64_sysv_elf_gas.o : asm/make_ppc64_sysv_elf_gas.S : @gas ]
[ make asm/jump_ppc64_sysv_elf_gas.o : asm/jump_ppc64_sysv_elf_gas.S : @gas ]
: <address-model>64
<architecture>power
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
<binary-format>elf
;

alias asm_context_sources
: asm/make_ppc64_sysv_macho_gas.S
asm/jump_ppc64_sysv_macho_gas.S
: [ make asm/make_ppc64_sysv_macho_gas.o : asm/make_ppc64_sysv_macho_gas.S : @gas ]
[ make asm/jump_ppc64_sysv_macho_gas.o : asm/jump_ppc64_sysv_macho_gas.S : @gas ]
untested.cpp
: <address-model>64
<architecture>power
<binary-format>mach-o
<target-os>darwin
<toolset>clang
;

alias asm_context_sources
: [ make asm/make_ppc64_sysv_elf_gas.o : asm/make_ppc64_sysv_elf_gas.S : @gas ]
[ make asm/jump_ppc64_sysv_elf_gas.o : asm/jump_ppc64_sysv_elf_gas.S : @gas ]
untested.cpp
: <address-model>64
<architecture>power
<binary-format>elf
;

alias asm_context_sources
Expand All @@ -227,14 +189,12 @@ alias asm_context_sources

# POWERPC universal
alias asm_context_sources
: asm/make_ppc32_ppc64_sysv_macho_gas.S
asm/jump_ppc32_ppc64_sysv_macho_gas.S
: [ make asm/make_ppc32_ppc64_sysv_macho_gas.o : asm/make_ppc32_ppc64_sysv_macho_gas.S : @gas ]
[ make asm/jump_ppc32_ppc64_sysv_macho_gas.o : asm/jump_ppc32_ppc64_sysv_macho_gas.S : @gas ]
untested.cpp
: <address-model>32_64
<architecture>power
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
;

# SPARC
Expand All @@ -259,31 +219,19 @@ alias asm_context_sources

# X86
alias asm_context_sources
: asm/make_i386_sysv_macho_gas.S
asm/jump_i386_sysv_macho_gas.S
: [ make asm/make_i386_sysv_elf_gas.o : asm/make_i386_sysv_elf_gas.S : @gas ]
[ make asm/jump_i386_sysv_elf_gas.o : asm/jump_i386_sysv_elf_gas.S : @gas ]
: <address-model>32
<architecture>x86
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
<binary-format>elf
;

alias asm_context_sources
: asm/make_i386_sysv_macho_gas.S
asm/jump_i386_sysv_macho_gas.S
: [ make asm/make_i386_sysv_macho_gas.o : asm/make_i386_sysv_macho_gas.S : @gas ]
[ make asm/jump_i386_sysv_macho_gas.o : asm/jump_i386_sysv_macho_gas.S : @gas ]
: <address-model>32
<architecture>x86
<binary-format>mach-o
<target-os>darwin
<toolset>clang
;

alias asm_context_sources
: [ make asm/make_i386_sysv_elf_gas.o : asm/make_i386_sysv_elf_gas.S : @gas ]
[ make asm/jump_i386_sysv_elf_gas.o : asm/jump_i386_sysv_elf_gas.S : @gas ]
: <address-model>32
<architecture>x86
<binary-format>elf
;

alias asm_context_sources
Expand All @@ -293,30 +241,9 @@ alias asm_context_sources
: <address-model>32
<architecture>x86
<binary-format>pe
<target-os>windows
;

# X86_64
alias asm_context_sources
: asm/make_x86_64_sysv_macho_gas.S
asm/jump_x86_64_sysv_macho_gas.S
: <address-model>64
<architecture>x86
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
;

alias asm_context_sources
: asm/make_x86_64_sysv_macho_gas.S
asm/jump_x86_64_sysv_macho_gas.S
: <address-model>64
<architecture>x86
<binary-format>mach-o
<target-os>darwin
<toolset>clang
;

alias asm_context_sources
: [ make asm/make_x86_64_sysv_elf_gas.o : asm/make_x86_64_sysv_elf_gas.S : @gas ]
[ make asm/jump_x86_64_sysv_elf_gas.o : asm/jump_x86_64_sysv_elf_gas.S : @gas ]
Expand All @@ -335,58 +262,40 @@ alias asm_context_sources
<abi>x32
;

alias asm_context_sources
: [ make asm/make_x86_64_sysv_macho_gas.o : asm/make_x86_64_sysv_macho_gas.S : @gas ]
[ make asm/jump_x86_64_sysv_macho_gas.o : asm/jump_x86_64_sysv_macho_gas.S : @gas ]
: <address-model>64
<architecture>x86
<binary-format>mach-o
;

alias asm_context_sources
: [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
[ make asm/jump_x86_64_ms_pe_masm.o : asm/jump_x86_64_ms_pe_masm.asm : @masm64 ]
dummy.cpp
: <address-model>64
<architecture>x86
<binary-format>pe
<target-os>windows
;

#X86 universal
alias asm_context_sources
: asm/make_i386_x86_64_sysv_macho_gas.S
asm/jump_i386_x86_64_sysv_macho_gas.S
: [ make asm/make_i386_x86_64_sysv_macho_gas.o : asm/make_i386_x86_64_sysv_macho_gas.S : @gas ]
[ make asm/jump_i386_x86_64_sysv_macho_gas.o : asm/jump_i386_x86_64_sysv_macho_gas.S : @gas ]
untested.cpp
: <address-model>32_64
<architecture>x86
<binary-format>mach-o
<target-os>darwin
;

# COMBINED
alias asm_context_sources
: asm/make_combined_sysv_macho_gas.S
asm/jump_combined_sysv_macho_gas.S
untested.cpp
: <address-model>32
<architecture>combined
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
;

alias asm_context_sources
: asm/make_combined_sysv_macho_gas.S
asm/jump_combined_sysv_macho_gas.S
untested.cpp
: <address-model>64
<architecture>combined
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
;

alias asm_context_sources
: asm/make_combined_sysv_macho_gas.S
asm/jump_combined_sysv_macho_gas.S
: [ make asm/make_combined_sysv_macho_gas.o : asm/make_combined_sysv_macho_gas.S : @gas ]
[ make asm/jump_combined_sysv_macho_gas.o : asm/jump_combined_sysv_macho_gas.S : @gas ]
untested.cpp
: <address-model>32_64
<architecture>combined
: <architecture>combined
<binary-format>mach-o
<target-os>darwin
<toolset>darwin
;

alias asm_context_sources
Expand Down
16 changes: 10 additions & 6 deletions src/asm/jump_ppc64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F30 | F31 | fpscr | R13 | *
* | F30 | F31 | fpscr | TOC | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
Expand Down Expand Up @@ -120,7 +120,9 @@ jump_fcontext:
# reserve space on stack
subi %r1, %r1, 328

std %r13, 152(%r1) # save R13
#if _CALL_ELF != 2
std %r2, 152(%r1) # save TOC
#endif
std %r14, 160(%r1) # save R14
std %r15, 168(%r1) # save R15
std %r16, 176(%r1) # save R16
Expand Down Expand Up @@ -176,7 +178,7 @@ jump_fcontext:

1:
# store RSP (pointing to context-data) in R3
stw %r1, 0(%r3)
std %r1, 0(%r3)

# restore RSP (pointing to context-data) from R4
mr %r1, %r4
Expand Down Expand Up @@ -207,7 +209,9 @@ jump_fcontext:
mtfsf 0xff, %f0 # restore FPSCR

2:
ld %r13, 152(%r1) # restore R13
#if _CALL_ELF != 2
ld %r2, 152(%r1) # restore TOC
#endif
ld %r14, 160(%r1) # restore R14
ld %r15, 168(%r1) # restore R15
ld %r16, 176(%r1) # restore R16
Expand Down Expand Up @@ -235,9 +239,9 @@ jump_fcontext:
mtlr %r0

# load PC
ld %r0, 320(%r1)
ld %r12, 320(%r1)
# restore CTR
mtctr %r0
mtctr %r12

# adjust stack
addi %r1, %r1, 328
Expand Down
25 changes: 18 additions & 7 deletions src/asm/make_ppc64_sysv_elf_gas.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F30 | F31 | fpscr | R13 | *
* | F30 | F31 | fpscr | TOC | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
Expand Down Expand Up @@ -120,16 +120,27 @@ make_fcontext:
# save return address into R6
mflr %r6

# first arg of make_fcontext() == top address of context-function
# first arg of make_fcontext() == top address of context-stack
# shift address in R3 to lower 16 byte boundary
clrrwi %r3, %r3, 4
clrrdi %r3, %r3, 4

# reserve space for context-data on context-stack
# including 64 byte of linkage + parameter area (R1 % 16 == 0)
subi %r3, %r3, 392

# third arg of make_fcontext() == address of context-function
stw %r5, 320(%r3)
# entry point (ELFv2) or descriptor (ELFv1)
#if _CALL_ELF == 2
# save address of context-function entry point
std %r5, 320(%r3)
#else
# save address of context-function entry point
ld %r4, 0(%r5)
std %r4, 320(%r3)
# save TOC of context-function
ld %r4, 8(%r5)
std %r4, 152(%r3)
#endif

# load LR
mflr %r0
Expand All @@ -144,7 +155,7 @@ make_fcontext:
mtlr %r0
# save address of finish as return-address for context-function
# will be entered after context-function returns
stw %r4, 312(%r3)
std %r4, 312(%r3)

# restore return address from R6
mtlr %r6
Expand All @@ -155,9 +166,9 @@ finish:
# save return address into R0
mflr %r0
# save return address on stack, set up stack frame
stw %r0, 8(%r1)
std %r0, 8(%r1)
# allocate stack space, R1 % 16 == 0
stwu %r1, -32(%r1)
stdu %r1, -32(%r1)

# exit code is zero
li %r3, 0
Expand Down

0 comments on commit 9f37c9b

Please sign in to comment.