<?xml version="1.0" encoding="UTF-8"?>

<compiler_spec>
  <!--
  	Assumes Procedure Call Standard for the ARM Architecture (AAPCS) Applies.
  -->
  <data_organization>  <!-- These tags were generated with gcc 4.2.4 -->
     <absolute_max_alignment value="0" />
     <machine_alignment value="2" />
     <default_alignment value="1" />
     <default_pointer_alignment value="4" />
     <pointer_size value="4" />
     <wchar_size value="4" />
     <short_size value="2" />
     <integer_size value="4" />
     <long_size value="4" />
     <long_long_size value="8" />
     <float_size value="4" />
     <double_size value="8" />
     <long_double_size value="8" />
     <size_alignment_map>
          <entry size="1" alignment="1" />
          <entry size="2" alignment="2" />
          <entry size="4" alignment="4" />
          <entry size="8" alignment="8" />
     </size_alignment_map>
  </data_organization>
  <global>
    <range space="ram"/>
  </global>
  <stackpointer register="sp" space="ram"/>
  
  <funcptr align="2"/>     <!-- Function pointers are word aligned and leastsig bit may encode otherstuff -->
  <default_proto>
    <prototype name="__stdcall" extrapop="0" stackshift="0">
      <input>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s0"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s1"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s2"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s3"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s4"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s5"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s6"/>
        </pentry>
        <pentry minsize="1" maxsize="4" metatype="float">
          <register name="s7"/>
        </pentry>
        <pentry minsize="1" maxsize="4" extension="inttype">
          <register name="r0"/>
        </pentry>
        <pentry minsize="1" maxsize="4" extension="inttype">
          <register name="r1"/>
        </pentry>
        <pentry minsize="1" maxsize="4" extension="inttype">
          <register name="r2"/>
        </pentry>
        <pentry minsize="1" maxsize="4" extension="inttype">
          <register name="r3"/>
        </pentry>
        <pentry minsize="1" maxsize="500" align="4">
          <addr offset="0" space="stack"/>
        </pentry>
      </input>
      <output>
        <pentry minsize="1" maxsize="8" metatype="float">
          <register name="d0"/>
        </pentry>
        <pentry minsize="1" maxsize="4" extension="inttype">
          <register name="r0"/>
        </pentry>
        <pentry minsize="5" maxsize="8">
          <addr space="join" piece1="r0" piece2="r1"/>
        </pentry>
      </output>
      <unaffected>
        <register name="r4"/>
        <register name="r5"/>
        <register name="r6"/>
        <register name="r7"/>
        <register name="r8"/>
        <register name="r9"/>
        <register name="r10"/>
        <register name="r11"/>
        <register name="d8"/>
        <register name="d9"/>
        <register name="d10"/>
        <register name="d11"/>
        <register name="d12"/>
        <register name="d13"/>
        <register name="d14"/>
        <register name="d15"/>
        <register name="sp"/>
      </unaffected>
      <killedbycall>
          <register name="r1"/>
          <register name="d0"/>
          <register name="d1"/>
          <register name="d2"/>
          <register name="d3"/>
          <register name="d4"/>
          <register name="d5"/>
          <register name="d6"/>
          <register name="d7"/>
      </killedbycall>
    </prototype>
  </default_proto>
  
  <callfixup name="switch8_r3">
    <target name="switch8_r3"/>
    <pcode>
      <body><![CDATA[
            tmpptr = lr - 1;
            tblsize = *:1 tmpptr;
            r12 = zext(tblsize);

            inbounds = r3 < r12;
            
            if (!inbounds) goto <next1>;
            offset = *:1 (lr + r3);
            r3 = zext(offset);
            <next1>
            
            if (inbounds) goto <next2>;
            offset = *:1 (lr + r12);
            r3 = zext(offset);
            <next2>
            
            r3 = r3 * 2;
            
            r12 = lr + r3;
            
            ISAModeSwitch = (r12 & 1) != 1;
            TB = ISAModeSwitch;
            pc = r12 & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
  <callfixup name="switch8_r0">
    <target name="__gnu_thumb1_case_uqi"/>
    <target name="switch8_r0"/>
    <pcode>
      <body><![CDATA[
            tmpptr = lr & 0xfffffffe;

            offset = *:1 (tmpptr + r0);
            offset = offset * 2;
            lr = lr + zext(offset);
 
            ISAModeSwitch = (lr & 1) != 0;
            TB = ISAModeSwitch;
            pc = lr & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
  <callfixup name="switchS8_r0">
    <target name="__gnu_thumb1_case_sqi"/>
    <target name="switchS8_r0"/>
    <pcode>
      <body><![CDATA[
            tmpptr = lr & 0xfffffffe;

            offset = *:1 (tmpptr + r0);
            offset = offset * 2;
            lr = lr + sext(offset);
 
            ISAModeSwitch = (lr & 1) != 0;
            TB = ISAModeSwitch;
            pc = lr & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
  <callfixup name="switch16_shi_r0">
    <target name="__gnu_thumb1_case_shi"/>
    <target name="switch16_shi_r0"/>
    <pcode>
      <body><![CDATA[
            tmpptr = lr & 0xfffffffe;
            
            index = r0 * 2;
            offset = *:2 (tmpptr + index);
            offset = offset * 2;
            lr = lr + sext(offset);
 
            ISAModeSwitch = (lr & 1) != 0;
            TB = ISAModeSwitch;
            pc = lr & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
  <callfixup name="switch16_uhi_r0">
    <target name="__gnu_thumb1_case_uhi"/>
    <target name="switch16_shi_r0"/>
    <pcode>
      <body><![CDATA[
            tmpptr = lr & 0xfffffffe;
            
            index = r0 * 2;
            offset = *:2 (tmpptr + index);
            offset = offset * 2;
            lr = lr + zext(offset);
 
            ISAModeSwitch = (lr & 1) != 0;
            TB = ISAModeSwitch;
            pc = lr & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
  <callfixup name="switch32_si_r0">
    <target name="__gnu_thumb1_case_si"/>
    <target name="switch32_si_r0"/>
    <pcode>
      <body><![CDATA[
            tmpptr = (lr + 2) & 0xfffffffc;
            
            index = r0 * 4;
            offset = *:4 (tmpptr + index);
            offset = offset * 4;
            lr = lr + offset;
 
            ISAModeSwitch = (lr & 1) != 0;
            TB = ISAModeSwitch;
            pc = lr & 0xfffffffe;
            goto [pc];
      ]]></body>
    </pcode>
  </callfixup>
  
</compiler_spec>
