<?xml version="1.0" encoding="UTF-8"?>
<!-- This cspec is based upon the PowerPC 64-bit ELF ABI specification -->
<compiler_spec>
  <data_organization>
	<pointer_size value="8"/>
  </data_organization>
  <global>
    <range space="ram"/>
  </global>
  <stackpointer register="r1" space="ram"/>
  <default_proto>
    <prototype name="__stdcall" extrapop="0" stackshift="0">
      <input>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f1"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f2"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f3"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f4"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f5"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f6"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f7"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f8"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f9"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f10"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f11"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f12"/>
        </pentry>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f13"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r3"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r4"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r5"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r6"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r7"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r8"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r9"/>
        </pentry>
        <pentry minsize="1" maxsize="8">
          <register name="r10"/>
        </pentry>
        <pentry minsize="1" maxsize="500" align="8">
          <addr offset="112" space="stack"/>
        </pentry>
      </input>
      <output>
        <pentry minsize="1" maxsize="8" metatype="float" extension="float">
          <register name="f1"/>
        </pentry>
        <pentry minsize="1" maxsize="8" extension="inttype">
          <register name="r3"/>
        </pentry>
      </output>
      <unaffected>
        <register name="r14"/>
        <register name="r15"/>
        <register name="r16"/>
        <register name="r17"/>
        <register name="r18"/>
        <register name="r19"/>
        <register name="r20"/>
        <register name="r21"/>
        <register name="r22"/>
        <register name="r23"/>
        <register name="r24"/>
        <register name="r25"/>
        <register name="r26"/>
        <register name="r27"/>
        <register name="r28"/>
        <register name="r29"/>
        <register name="r30"/>
        <register name="r31"/>
        <register name="r1"/>
        <!-- In cases where r2 does change, we assume it will get restored -->
        <register name="r2"/>
        <register name="r2Save"/>
      </unaffected>
      <pcode inject="uponreturn">
      	<body>
      		# Inject pcode when returning from a function call to place the r2Save
      		# value into 0x28(r1) which should be restored by the "ld r2,0x28(r1)" 
      		# which immediately follows calls which comply with the PPC64 ABI spec.
      		local saveR2ptr = r1 + 0x28;
      		*:8 saveR2ptr = r2Save; 
      	</body>
      </pcode>
    </prototype>
  </default_proto>
</compiler_spec>
