require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_AMD64_MACHINE_FRAMEASM_H)) {
    eval 'sub _AMD64_MACHINE_FRAMEASM_H () {1;}' unless defined(&_AMD64_MACHINE_FRAMEASM_H);
    eval 'sub INTR_SAVE_GPRS () { &subq $120,% &rsp ;  &movq % &r15, &TF_R15(% &rsp) ;  &movq % &r14, &TF_R14(% &rsp) ;  &movq % &r13, &TF_R13(% &rsp) ;  &movq % &r12, &TF_R12(% &rsp) ;  &movq % &r11, &TF_R11(% &rsp) ;  &movq % &r10, &TF_R10(% &rsp) ;  &movq % &r9, &TF_R9(% &rsp) ;  &movq % &r8, &TF_R8(% &rsp) ;  &movq % &rdi, &TF_RDI(% &rsp) ;  &movq % &rsi, &TF_RSI(% &rsp) ;  &movq % &rbp, &TF_RBP(% &rsp) ;  &movq % &rbx, &TF_RBX(% &rsp) ;  &movq % &rdx, &TF_RDX(% &rsp) ;  &movq % &rcx, &TF_RCX(% &rsp) ;  &movq % &rax, &TF_RAX(% &rsp);}' unless defined(&INTR_SAVE_GPRS);
    eval 'sub INTR_RESTORE_GPRS () { &movq  &TF_R15(% &rsp),% &r15 ;  &movq  &TF_R14(% &rsp),% &r14 ;  &movq  &TF_R13(% &rsp),% &r13 ;  &movq  &TF_R12(% &rsp),% &r12 ;  &movq  &TF_R11(% &rsp),% &r11 ;  &movq  &TF_R10(% &rsp),% &r10 ;  &movq  &TF_R9(% &rsp),% &r9 ;  &movq  &TF_R8(% &rsp),% &r8 ;  &movq  &TF_RDI(% &rsp),% &rdi ;  &movq  &TF_RSI(% &rsp),% &rsi ;  &movq  &TF_RBP(% &rsp),% &rbp ;  &movq  &TF_RBX(% &rsp),% &rbx ;  &movq  &TF_RDX(% &rsp),% &rdx ;  &movq  &TF_RCX(% &rsp),% &rcx ;  &movq  &TF_RAX(% &rsp),% &rax ;  &addq $120,% &rsp;}' unless defined(&INTR_RESTORE_GPRS);
    eval 'sub INTRENTRY () { &subq $32,% &rsp ;  &testq $ &SEL_UPL,56(% &rsp) ;  &je 98 &f ;  &swapgs ;  &movw % &gs,0(% &rsp) ;  &movw % &fs,8(% &rsp) ;  &movw % &es,16(% &rsp) ;  &movw % &ds,24(% &rsp) ; 98:  &INTR_SAVE_GPRS;}' unless defined(&INTRENTRY);
    eval 'sub INTRFASTEXIT () { &INTR_RESTORE_GPRS ;  &testq $ &SEL_UPL,56(% &rsp) ;  &je 99 &f ;  &cli ;  &swapgs ;  &movw 0(% &rsp),% &gs ;  &movw 8(% &rsp),% &fs ;  &movw 16(% &rsp),% &es ;  &movw 24(% &rsp),% &ds ; 99:  &addq $48,% &rsp ;  &iretq;}' unless defined(&INTRFASTEXIT);
    eval 'sub INTR_RECURSE_HWFRAME () { &movq % &rsp,% &r10 ;  &movl % &ss,% &r11d ;  &pushq % &r11 ;  &pushq % &r10 ;  &pushfq ;  &movl % &cs,% &r11d ;  &pushq % &r11 ;  &pushq % &r13 ;;}' unless defined(&INTR_RECURSE_HWFRAME);
    eval 'sub CHECK_ASTPENDING {
        my($reg) = @_;
	    eval q( &movq  &CPUVAR( &CURPROC),$reg ;  &cmpq $0, $reg ;  &je 99 &f ;  &cmpl $0,  &P_MD_ASTPENDING($reg) ; 99:);
    }' unless defined(&CHECK_ASTPENDING);
    eval 'sub CLEAR_ASTPENDING {
        my($reg) = @_;
	    eval q( &movl $0,  &P_MD_ASTPENDING($reg));
    }' unless defined(&CLEAR_ASTPENDING);
}
1;
