text: #!/usr/bin/env python3
  
  #
  # Copyright (C) [2020] Futurewei Technologies, Inc.
  #
  # FORCE-RISCV is licensed under the Apache License, Version 2.0
  #  (the "License"); you may not use this file except in compliance
  #  with the License.  You may obtain a copy of the License at
  #
  #  http://www.apache.org/licenses/LICENSE-2.0
  #
  # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
  # OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  # NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  
  """
  This script needs to be run before make whenever changes have been made to
  pike or Handcar base code
  """
  
  import errno
  import glob
  import os
  import shutil
  
  # Controls
  NOISY = True
  
  ORIGINAL_SOURCE_DIRECTORY = "standalone"
  ORIGINAL_SOFTFLOAT_DIRECTORY = "standalone/softfloat"
  ORIGINAL_INSTRUCTIONS_DIRECTORY = "standalone"
  ORIGINAL_INSTRUCTION_HEADERS_DIRECTORY = "standalone/riscv/insns"
  REPLACEMENTS_DIRECTORY = "spike_mod"
  
  # These instruction files are generated during the configuration phase of an
  # Original Spike build.
  INSTRUCTION_SOURCE_FILENAMES = [
      "amoadd_d.cc",
      "amoadd_w.cc",
      "amoand_d.cc",
      "amoand_w.cc",
      "amomax_d.cc",
      "amomaxu_d.cc",
      "amomaxu_w.cc",
      "amomax_w.cc",
      "amomin_d.cc",
      "amominu_d.cc",
      "amominu_w.cc",
      "amomin_w.cc",
      "amoor_d.cc",
      "amoor_w.cc",
      "amoswap_d.cc",
      "amoswap_w.cc",
      "amoxor_d.cc",
      "amoxor_w.cc",
      "lr_d.cc",
      "lr_w.cc",
      "sc_d.cc",
      "sc_w.cc",
      "c_add.cc",
      "c_addi.cc",
      "c_addi4spn.cc",
      "c_addw.cc",
      "c_and.cc",
      "c_andi.cc",
      "c_beqz.cc",
      "c_bnez.cc",
      "c_ebreak.cc",
      "c_fld.cc",
      "c_fldsp.cc",
      "c_flw.cc",
      "c_flwsp.cc",
      "c_fsd.cc",
      "c_fsdsp.cc",
      "c_fsw.cc",
      "c_fswsp.cc",
      "c_j.cc",
      "c_jal.cc",
      "c_jalr.cc",
      "c_jr.cc",
      "c_li.cc",
      "c_lui.cc",
      "c_lw.cc",
      "c_lwsp.cc",
      "c_mv.cc",
      "c_or.cc",
      "c_slli.cc",
      "c_srai.cc",
      "c_srli.cc",
      "c_sub.cc",
      "c_subw.cc",
      "c_sw.cc",
      "c_swsp.cc",
      "c_xor.cc",
      "add.cc",
      "addi.cc",
      "addiw.cc",
      "addw.cc",
      "and.cc",
      "andi.cc",
      "auipc.cc",
      "beq.cc",
      "bge.cc",
      "bgeu.cc",
      "blt.cc",
      "bltu.cc",
      "bne.cc",
      "jal.cc",
      "jalr.cc",
      "lb.cc",
      "lbu.cc",
      "ld.cc",
      "lh.cc",
      "lhu.cc",
      "lui.cc",
      "lw.cc",
      "lwu.cc",
      "or.cc",
      "ori.cc",
      "sb.cc",
      "sd.cc",
      "sh.cc",
      "sll.cc",
      "slli.cc",
      "slliw.cc",
      "sllw.cc",
      "slt.cc",
      "slti.cc",
      "sltiu.cc",
      "sltu.cc",
      "sra.cc",
      "srai.cc",
      "sraiw.cc",
      "sraw.cc",
      "srl.cc",
      "srli.cc",
      "srliw.cc",
      "srlw.cc",
      "sub.cc",
      "subw.cc",
      "sw.cc",
      "xor.cc",
      "xori.cc",
      "fence.cc",
      "fence_i.cc",
      "div.cc",
      "divu.cc",
      "divuw.cc",
      "divw.cc",
      "mul.cc",
      "mulh.cc",
      "mulhsu.cc",
      "mulhu.cc",
      "mulw.cc",
      "rem.cc",
      "remu.cc",
      "remuw.cc",
      "remw.cc",
      "fadd_s.cc",
      "fclass_s.cc",
      "fcvt_l_s.cc",
      "fcvt_lu_s.cc",
      "fcvt_s_l.cc",
      "fcvt_s_lu.cc",
      "fcvt_s_w.cc",
      "fcvt_s_wu.cc",
      "fcvt_w_s.cc",
      "fcvt_wu_s.cc",
      "fdiv_s.cc",
      "feq_s.cc",
      "fle_s.cc",
      "flt_s.cc",
      "flw.cc",
      "fmadd_s.cc",
      "fmax_s.cc",
      "fmin_s.cc",
      "fmsub_s.cc",
      "fmul_s.cc",
      "fmv_w_x.cc",
      "fmv_x_w.cc",
      "fnmadd_s.cc",
      "fnmsub_s.cc",
      "fsgnj_s.cc",
      "fsgnjn_s.cc",
      "fsgnjx_s.cc",
      "fsqrt_s.cc",
      "fsub_s.cc",
      "fsw.cc",
      "fadd_d.cc",
      "fclass_d.cc",
      "fcvt_d_l.cc",
      "fcvt_d_lu.cc",
      "fcvt_d_q.cc",
      "fcvt_d_s.cc",
      "fcvt_d_w.cc",
      "fcvt_d_wu.cc",
      "fcvt_l_d.cc",
      "fcvt_lu_d.cc",
      "fcvt_s_d.cc",
      "fcvt_w_d.cc",
      "fcvt_wu_d.cc",
      "fdiv_d.cc",
      "feq_d.cc",
      "fld.cc",
      "fle_d.cc",
      "flt_d.cc",
      "fmadd_d.cc",
      "fmax_d.cc",
      "fmin_d.cc",
      "fmsub_d.cc",
      "fmul_d.cc",
      "fmv_d_x.cc",
      "fmv_x_d.cc",
      "fnmadd_d.cc",
      "fnmsub_d.cc",
      "fsd.cc",
      "fsgnj_d.cc",
      "fsgnjn_d.cc",
      "fsgnjx_d.cc",
      "fsqrt_d.cc",
      "fsub_d.cc",
      "fadd_h.cc",
      "fclass_h.cc",
      "fcvt_l_h.cc",
      "fcvt_lu_h.cc",
      "fcvt_d_h.cc",
      "fcvt_h_d.cc",
      "fcvt_h_l.cc",
      "fcvt_h_lu.cc",
      "fcvt_h_q.cc",
      "fcvt_h_s.cc",
      "fcvt_h_w.cc",
      "fcvt_h_wu.cc",
      "fcvt_q_h.cc",
      "fcvt_s_h.cc",
      "fcvt_w_h.cc",
      "fcvt_wu_h.cc",
      "fdiv_h.cc",
      "feq_h.cc",
      "fle_h.cc",
      "flh.cc",
      "flt_h.cc",
      "fmadd_h.cc",
      "fmax_h.cc",
      "fmin_h.cc",
      "fmsub_h.cc",
      "fmul_h.cc",
      "fmv_h_x.cc",
      "fmv_x_h.cc",
      "fnmadd_h.cc",
      "fnmsub_h.cc",
      "fsgnj_h.cc",
      "fsgnjn_h.cc",
      "fsgnjx_h.cc",
      "fsh.cc",
      "fsqrt_h.cc",
      "fsub_h.cc",
      "fadd_q.cc",
      "fclass_q.cc",
      "fcvt_l_q.cc",
      "fcvt_lu_q.cc",
      "fcvt_q_d.cc",
      "fcvt_q_l.cc",
      "fcvt_q_lu.cc",
      "fcvt_q_s.cc",
      "fcvt_q_w.cc",
      "fcvt_q_wu.cc",
      "fcvt_s_q.cc",
      "fcvt_w_q.cc",
      "fcvt_wu_q.cc",
      "fdiv_q.cc",
      "feq_q.cc",
      "fle_q.cc",
      "flq.cc",
      "flt_q.cc",
      "fmadd_q.cc",
      "fmax_q.cc",
      "fmin_q.cc",
      "fmsub_q.cc",
      "fmul_q.cc",
      "fnmadd_q.cc",
      "fnmsub_q.cc",
      "fsgnj_q.cc",
      "fsgnjn_q.cc",
      "fsgnjx_q.cc",
      "fsq.cc",
      "fsqrt_q.cc",
      "fsub_q.cc",
      "vfadd_vf.cc",
      "vfadd_vv.cc",
      "vfclass_v.cc",
      "vfcvt_rtz_x_f_v.cc",
      "vfcvt_rtz_xu_f_v.cc",
      "vfncvt_rtz_x_f_w.cc",
      "vfncvt_rtz_xu_f_w.cc",
      "vfwcvt_rtz_x_f_v.cc",
      "vfwcvt_rtz_xu_f_v.cc",
      "vfslide1down_vf.cc",
      "vfslide1up_vf.cc",
      "vsext_vf2.cc",
      "vsext_vf4.cc",
      "vsext_vf8.cc",
      "vzext_vf2.cc",
      "vzext_vf4.cc",
      "vzext_vf8.cc",
      "vamoswape8_v.cc",
      "vamoadde8_v.cc",
      "vamoande8_v.cc",
      "vamomaxe8_v.cc",
      "vamomaxue8_v.cc",
      "vamomine8_v.cc",
      "vamominue8_v.cc",
      "vamoore8_v.cc",
      "vamoxore8_v.cc",
      "vamoswape16_v.cc",
      "vamoadde16_v.cc",
      "vamoande16_v.cc",
      "vamomaxe16_v.cc",
      "vamomaxue16_v.cc",
      "vamomine16_v.cc",
      "vamominue16_v.cc",
      "vamoore16_v.cc",
      "vamoxore16_v.cc",
      "vamoswape32_v.cc",
      "vamoadde32_v.cc",
      "vamoande32_v.cc",
      "vamomaxe32_v.cc",
      "vamomaxue32_v.cc",
      "vamomine32_v.cc",
      "vamominue32_v.cc",
      "vamoore32_v.cc",
      "vamoxore32_v.cc",
      "vamoswape64_v.cc",
      "vamoadde64_v.cc",
      "vamoande64_v.cc",
      "vamomaxe64_v.cc",
      "vamomaxue64_v.cc",
      "vamomine64_v.cc",
      "vamominue64_v.cc",
      "vamoore64_v.cc",
      "vamoxore64_v.cc",
      "vle8_v.cc",
      "vle16_v.cc",
      "vle32_v.cc",
      "vle64_v.cc",
      "vlse8_v.cc",
      "vlse16_v.cc",
      "vlse32_v.cc",
      "vlse64_v.cc",
      "vlxei8_v.cc",
      "vlxei16_v.cc",
      "vlxei32_v.cc",
      "vlxei64_v.cc",
      "vle8ff_v.cc",
      "vle16ff_v.cc",
      "vle32ff_v.cc",
      "vle64ff_v.cc",
      "vse8_v.cc",
      "vse16_v.cc",
      "vse32_v.cc",
      "vse64_v.cc",
      "vsse8_v.cc",
      "vsse16_v.cc",
      "vsse32_v.cc",
      "vsse64_v.cc",
      "vsxei8_v.cc",
      "vsxei16_v.cc",
      "vsxei32_v.cc",
      "vsxei64_v.cc",
      "vsuxei8_v.cc",
      "vsuxei16_v.cc",
      "vsuxei32_v.cc",
      "vsuxei64_v.cc",
      "vfcvt_f_x_v.cc",
      "vfcvt_f_xu_v.cc",
      "vfcvt_x_f_v.cc",
      "vfcvt_xu_f_v.cc",
      "vfdiv_vf.cc",
      "vfdiv_vv.cc",
      "vfdot_vv.cc",
      "vfmacc_vf.cc",
      "vfmacc_vv.cc",
      "vfmadd_vf.cc",
      "vfmadd_vv.cc",
      "vfmax_vf.cc",
      "vfmax_vv.cc",
      "vfmerge_vfm.cc",
      "vfmin_vf.cc",
      "vfmin_vv.cc",
      "vfmsac_vf.cc",
      "vfmsac_vv.cc",
      "vfmsub_vf.cc",
      "vfmsub_vv.cc",
      "vfmul_vf.cc",
      "vfmul_vv.cc",
      "vfmv_f_s.cc",
      "vfmv_s_f.cc",
      "vfmv_v_f.cc",
      "vfncvt_f_f_w.cc",
      "vfncvt_f_x_w.cc",
      "vfncvt_f_xu_w.cc",
      "vfncvt_rod_f_f_w.cc",
      "vfncvt_x_f_w.cc",
      "vfncvt_xu_f_w.cc",
      "vfnmacc_vf.cc",
      "vfnmacc_vv.cc",
      "vfnmadd_vf.cc",
      "vfnmadd_vv.cc",
      "vfnmsac_vf.cc",
      "vfnmsac_vv.cc",
      "vfnmsub_vf.cc",
      "vfnmsub_vv.cc",
      "vfrdiv_vf.cc",
      "vfredmax_vs.cc",
      "vfredmin_vs.cc",
      "vfredosum_vs.cc",
      "vfredsum_vs.cc",
      "vfrsub_vf.cc",
      "vfsgnj_vf.cc",
      "vfsgnj_vv.cc",
      "vfsgnjn_vf.cc",
      "vfsgnjn_vv.cc",
      "vfsgnjx_vf.cc",
      "vfsgnjx_vv.cc",
      "vfsqrt_v.cc",
      "vfsub_vf.cc",
      "vfsub_vv.cc",
      "vfwadd_vf.cc",
      "vfwadd_vv.cc",
      "vfwadd_wf.cc",
      "vfwadd_wv.cc",
      "vfwcvt_f_f_v.cc",
      "vfwcvt_f_x_v.cc",
      "vfwcvt_f_xu_v.cc",
      "vfwcvt_x_f_v.cc",
      "vfwcvt_xu_f_v.cc",
      "vfwmacc_vf.cc",
      "vfwmacc_vv.cc",
      "vfwmsac_vf.cc",
      "vfwmsac_vv.cc",
      "vfwmul_vf.cc",
      "vfwmul_vv.cc",
      "vfwnmacc_vf.cc",
      "vfwnmacc_vv.cc",
      "vfwnmsac_vf.cc",
      "vfwnmsac_vv.cc",
      "vfwredosum_vs.cc",
      "vfwredsum_vs.cc",
      "vfwsub_vf.cc",
      "vfwsub_vv.cc",
      "vfwsub_wf.cc",
      "vfwsub_wv.cc",
      "vmfeq_vf.cc",
      "vmfeq_vv.cc",
      "vmfge_vf.cc",
      "vmfgt_vf.cc",
      "vmfle_vf.cc",
      "vmfle_vv.cc",
      "vmflt_vf.cc",
      "vmflt_vv.cc",
      "vmfne_vf.cc",
      "vmfne_vv.cc",
      "vaadd_vv.cc",
      "vaaddu_vv.cc",
      "vaadd_vx.cc",
      "vaaddu_vx.cc",
      "vadc_vim.cc",
      "vadc_vvm.cc",
      "vadc_vxm.cc",
      "vadd_vi.cc",
      "vadd_vv.cc",
      "vadd_vx.cc",
      "vand_vi.cc",
      "vand_vv.cc",
      "vand_vx.cc",
      "vasub_vv.cc",
      "vasubu_vv.cc",
      "vasub_vx.cc",
      "vasubu_vx.cc",
      "vcompress_vm.cc",
      "vdiv_vv.cc",
      "vdiv_vx.cc",
      "vdivu_vv.cc",
      "vdivu_vx.cc",
      "vdot_vv.cc",
      "vdotu_vv.cc",
      "vid_v.cc",
      "viota_m.cc",
      "vmacc_vv.cc",
      "vmacc_vx.cc",
      "vmadc_vim.cc",
      "vmadc_vvm.cc",
      "vmadc_vxm.cc",
      "vmadd_vv.cc",
      "vmadd_vx.cc",
      "vmand_mm.cc",
      "vmandnot_mm.cc",
      "vmax_vv.cc",
      "vmax_vx.cc",
      "vmaxu_vv.cc",
      "vmaxu_vx.cc",
      "vmerge_vim.cc",
      "vmerge_vvm.cc",
      "vmerge_vxm.cc",
      "vfirst_m.cc",
      "vmin_vv.cc",
      "vmin_vx.cc",
      "vminu_vv.cc",
      "vminu_vx.cc",
      "vmnand_mm.cc",
      "vmnor_mm.cc",
      "vmor_mm.cc",
      "vmornot_mm.cc",
      "vpopc_m.cc",
      "vmsbc_vvm.cc",
      "vmsbc_vxm.cc",
      "vmsbf_m.cc",
      "vmseq_vi.cc",
      "vmseq_vv.cc",
      "vmseq_vx.cc",
      "vmsgt_vi.cc",
      "vmsgt_vx.cc",
      "vmsgtu_vi.cc",
      "vmsgtu_vx.cc",
      "vmsif_m.cc",
      "vmsle_vi.cc",
      "vmsle_vv.cc",
      "vmsle_vx.cc",
      "vmsleu_vi.cc",
      "vmsleu_vv.cc",
      "vmsleu_vx.cc",
      "vmslt_vv.cc",
      "vmslt_vx.cc",
      "vmsltu_vv.cc",
      "vmsltu_vx.cc",
      "vmsne_vi.cc",
      "vmsne_vv.cc",
      "vmsne_vx.cc",
      "vmsof_m.cc",
      "vmul_vv.cc",
      "vmul_vx.cc",
      "vmulh_vv.cc",
      "vmulh_vx.cc",
      "vmulhsu_vv.cc",
      "vmulhsu_vx.cc",
      "vmulhu_vv.cc",
      "vmulhu_vx.cc",
      "vmv_s_x.cc",
      "vmv_v_i.cc",
      "vmv_v_v.cc",
      "vmv_v_x.cc",
      "vmv_x_s.cc",
      "vmv1r_v.cc",
      "vmv2r_v.cc",
      "vmv4r_v.cc",
      "vmv8r_v.cc",
      "vmxnor_mm.cc",
      "vmxor_mm.cc",
      "vnclip_wi.cc",
      "vnclip_wv.cc",
      "vnclip_wx.cc",
      "vnclipu_wi.cc",
      "vnclipu_wv.cc",
      "vnclipu_wx.cc",
      "vnmsac_vv.cc",
      "vnmsac_vx.cc",
      "vnmsub_vv.cc",
      "vnmsub_vx.cc",
      "vnsra_wi.cc",
      "vnsra_wv.cc",
      "vnsra_wx.cc",
      "vnsrl_wi.cc",
      "vnsrl_wv.cc",
      "vnsrl_wx.cc",
      "vor_vi.cc",
      "vor_vv.cc",
      "vor_vx.cc",
      "vqmacc_vv.cc",
      "vqmacc_vx.cc",
      "vqmaccsu_vv.cc",
      "vqmaccsu_vx.cc",
      "vqmaccu_vv.cc",
      "vqmaccu_vx.cc",
      "vqmaccus_vx.cc",
      "vredand_vs.cc",
      "vredmax_vs.cc",
      "vredmaxu_vs.cc",
      "vredmin_vs.cc",
      "vredminu_vs.cc",
      "vredor_vs.cc",
      "vredsum_vs.cc",
      "vredxor_vs.cc",
      "vrem_vv.cc",
      "vrem_vx.cc",
      "vremu_vv.cc",
      "vremu_vx.cc",
      "vrgather_vi.cc",
      "vrgather_vv.cc",
      "vrgather_vx.cc",
      "vrsub_vi.cc",
      "vrsub_vx.cc",
      "vsadd_vi.cc",
      "vsadd_vv.cc",
      "vsadd_vx.cc",
      "vsaddu_vi.cc",
      "vsaddu_vv.cc",
      "vsaddu_vx.cc",
      "vsbc_vvm.cc",
      "vsbc_vxm.cc",
      "vslide1down_vx.cc",
      "vslide1up_vx.cc",
      "vslidedown_vi.cc",
      "vslidedown_vx.cc",
      "vslideup_vi.cc",
      "vslideup_vx.cc",
      "vsll_vi.cc",
      "vsll_vv.cc",
      "vsll_vx.cc",
      "vsmul_vv.cc",
      "vsmul_vx.cc",
      "vsra_vi.cc",
      "vsra_vv.cc",
      "vsra_vx.cc",
      "vsrl_vi.cc",
      "vsrl_vv.cc",
      "vsrl_vx.cc",
      "vssra_vi.cc",
      "vssra_vv.cc",
      "vssra_vx.cc",
      "vssrl_vi.cc",
      "vssrl_vv.cc",
      "vssrl_vx.cc",
      "vssub_vv.cc",
      "vssub_vx.cc",
      "vssubu_vv.cc",
      "vssubu_vx.cc",
      "vsub_vv.cc",
      "vsub_vx.cc",
      "vwadd_vv.cc",
      "vwadd_vx.cc",
      "vwadd_wv.cc",
      "vwadd_wx.cc",
      "vwaddu_vv.cc",
      "vwaddu_vx.cc",
      "vwaddu_wv.cc",
      "vwaddu_wx.cc",
      "vwmacc_vv.cc",
      "vwmacc_vx.cc",
      "vwmaccsu_vv.cc",
      "vwmaccsu_vx.cc",
      "vwmaccu_vv.cc",
      "vwmaccu_vx.cc",
      "vwmaccus_vx.cc",
      "vwmul_vv.cc",
      "vwmul_vx.cc",
      "vwmulsu_vv.cc",
      "vwmulsu_vx.cc",
      "vwmulu_vv.cc",
      "vwmulu_vx.cc",
      "vwredsum_vs.cc",
      "vwredsumu_vs.cc",
      "vwsub_vv.cc",
      "vwsub_vx.cc",
      "vwsub_wv.cc",
      "vwsub_wx.cc",
      "vwsubu_vv.cc",
      "vwsubu_vx.cc",
      "vwsubu_wv.cc",
      "vwsubu_wx.cc",
      "vxor_vi.cc",
      "vxor_vv.cc",
      "vxor_vx.cc",
      "vsetvli.cc",
      "vsetvl.cc",
      "vl1r_v.cc",
      "vs1r_v.cc",
      "csrrc.cc",
      "csrrci.cc",
      "csrrs.cc",
      "csrrsi.cc",
      "csrrw.cc",
      "csrrwi.cc",
      "dret.cc",
      "ebreak.cc",
      "ecall.cc",
      "mret.cc",
      "sfence_vma.cc",
      "sret.cc",
      "wfi.cc",
  ]
  
  INSTRUCTION_HEADER_FILENAMES = [
      "fadd_h.h",
      "fclass_h.h",
      "fcvt_l_h.h",
      "fcvt_lu_h.h",
      "fcvt_d_h.h",
      "fcvt_h_d.h",
      "fcvt_h_l.h",
      "fcvt_h_lu.h",
      "fcvt_h_q.h",
      "fcvt_h_s.h",
      "fcvt_h_w.h",
      "fcvt_h_wu.h",
      "fcvt_q_h.h",
      "fcvt_s_h.h",
      "fcvt_w_h.h",
      "fcvt_wu_h.h",
      "fdiv_h.h",
      "feq_h.h",
      "fle_h.h",
      "flh.h",
      "flt_h.h",
      "fmadd_h.h",
      "fmax_h.h",
      "fmin_h.h",
      "fmsub_h.h",
      "fmul_h.h",
      "fmv_h_x.h",
      "fmv_x_h.h",
      "fnmadd_h.h",
      "fnmsub_h.h",
      "fsgnj_h.h",
      "fsgnjn_h.h",
      "fsgnjx_h.h",
      "fsh.h",
      "fsqrt_h.h",
      "fsub_h.h",
      "vfcvt_rtz_x_f_v.h",
      "vfcvt_rtz_xu_f_v.h",
      "vfncvt_rtz_x_f_w.h",
      "vfncvt_rtz_xu_f_w.h",
      "vfslide1down_vf.h",
      "vfslide1up_vf.h",
      "vfwcvt_rtz_x_f_v.h",
      "vfwcvt_rtz_xu_f_v.h",
      "vsext_vf2.h",
      "vsext_vf4.h",
      "vsext_vf8.h",
      "vzext_vf2.h",
      "vzext_vf4.h",
      "vzext_vf8.h",
      "vamoswape8_v.h",
      "vamoadde8_v.h",
      "vamoande8_v.h",
      "vamomaxe8_v.h",
      "vamomaxue8_v.h",
      "vamomine8_v.h",
      "vamominue8_v.h",
      "vamoore8_v.h",
      "vamoxore8_v.h",
      "vamoswape16_v.h",
      "vamoadde16_v.h",
      "vamoande16_v.h",
      "vamomaxe16_v.h",
      "vamomaxue16_v.h",
      "vamomine16_v.h",
      "vamominue16_v.h",
      "vamoore16_v.h",
      "vamoxore16_v.h",
      "vamoswape32_v.h",
      "vamoadde32_v.h",
      "vamoande32_v.h",
      "vamomaxe32_v.h",
      "vamomaxue32_v.h",
      "vamomine32_v.h",
      "vamominue32_v.h",
      "vamoore32_v.h",
      "vamoxore32_v.h",
      "vamoswape64_v.h",
      "vamoadde64_v.h",
      "vamoande64_v.h",
      "vamomaxe64_v.h",
      "vamomaxue64_v.h",
      "vamomine64_v.h",
      "vamominue64_v.h",
      "vamoore64_v.h",
      "vamoxore64_v.h",
      "vle8_v.h",
      "vle16_v.h",
      "vle32_v.h",
      "vle64_v.h",
      "vlse8_v.h",
      "vlse16_v.h",
      "vlse32_v.h",
      "vlse64_v.h",
      "vlxei8_v.h",
      "vlxei16_v.h",
      "vlxei32_v.h",
      "vlxei64_v.h",
      "vle8ff_v.h",
      "vle16ff_v.h",
      "vle32ff_v.h",
      "vle64ff_v.h",
      "vse8_v.h",
      "vse16_v.h",
      "vse32_v.h",
      "vse64_v.h",
      "vsse8_v.h",
      "vsse16_v.h",
      "vsse32_v.h",
      "vsse64_v.h",
      "vsxei8_v.h",
      "vsxei16_v.h",
      "vsxei32_v.h",
      "vsxei64_v.h",
      "vsuxei8_v.h",
      "vsuxei16_v.h",
      "vsuxei32_v.h",
      "vsuxei64_v.h",
      "add.h",
      "c_beqz.h",
      "divuw.h",
      "fcvt_w_s.h",
      "fmv_w_x.h",
      "lw.h",
      "sub.h",
      "vfdot_vv.h",
      "vfredosum_vs.h",
      "vid_v.h",
      "vmadd_vx.h",
      "vmsgt_vx.h",
      "vnclipu_wv.h",
      "vrem_vx.h",
      "vwmaccu_vx.h",
      "addi.h",
      "c_bnez.h",
      "divw.h",
      "fcvt_wu_d.h",
      "fmv_x_d.h",
      "lwu.h",
      "subw.h",
      "vfirst_m.h",
      "vfredsum_vs.h",
      "viota_m.h",
      "vmand_mm.h",
      "vmsif_m.h",
      "vnclipu_wx.h",
      "vrgather_vi.h",
      "vwmacc_vv.h",
      "addiw.h",
      "c_ebreak.h",
      "dret.h",
      "fcvt_wu_q.h",
      "fmv_x_w.h",
      "mret.h",
      "sw.h",
      "vfmacc_vf.h",
      "vfrsub_vf.h",
      "vl1r_v.h",
      "vmandnot_mm.h",
      "vmsleu_vi.h",
      "vnclip_wi.h",
      "vrgather_vv.h",
      "vwmacc_vx.h",
      "addw.h",
      "c_fld.h",
      "ebreak.h",
      "fcvt_wu_s.h",
      "fnmadd_d.h",
      "mul.h",
      "vaaddu_vv.h",
      "vfmacc_vv.h",
      "vfsgnjn_vf.h",
      "vmaxu_vv.h",
      "vmsleu_vv.h",
      "vnclip_wv.h",
      "vrgather_vx.h",
      "vssra_vi.h",
      "vwmulsu_vv.h",
      "amoadd_d.h",
      "c_fldsp.h",
      "ecall.h",
      "fdiv_d.h",
      "fnmadd_q.h",
      "mulh.h",
      "vaaddu_vx.h",
      "vfmadd_vf.h",
      "vfsgnjn_vv.h",
      "vmaxu_vx.h",
      "vmsleu_vx.h",
      "vnclip_wx.h",
      "vrsub_vi.h",
      "vssra_vv.h",
      "vwmulsu_vx.h",
      "amoadd_w.h",
      "c_flw.h",
      "fadd_d.h",
      "fdiv_q.h",
      "fnmadd_s.h",
      "mulhsu.h",
      "vfmadd_vv.h",
      "vfsgnj_vf.h",
      "vmax_vv.h",
      "vmsle_vi.h",
      "vnmsac_vv.h",
      "vrsub_vx.h",
      "vssra_vx.h",
      "vwmulu_vv.h",
      "amoand_d.h",
      "c_flwsp.h",
      "fadd_q.h",
      "fdiv_s.h",
      "fnmsub_d.h",
      "mulhu.h",
      "vaadd_vv.h",
      "vfmax_vf.h",
      "vfsgnj_vv.h",
      "vmax_vx.h",
      "vmsle_vv.h",
      "vnmsac_vx.h",
      "vs1r_v.h",
      "vssrl_vi.h",
      "vwmulu_vx.h",
      "amoand_w.h",
      "c_fsd.h",
      "fadd_s.h",
      "fence.h",
      "fnmsub_q.h",
      "mulw.h",
      "vaadd_vx.h",
      "vfmax_vv.h",
      "vfsgnjx_vf.h",
      "vmerge_vim.h",
      "vmsle_vx.h",
      "vnmsub_vv.h",
      "vsaddu_vi.h",
      "vssrl_vv.h",
      "vwmul_vv.h",
      "amomax_d.h",
      "c_fsdsp.h",
      "fclass_d.h",
      "fence_i.h",
      "fnmsub_s.h",
      "or.h",
      "vadc_vim.h",
      "vfmerge_vfm.h",
      "vfsgnjx_vv.h",
      "vmerge_vvm.h",
      "vmsltu_vv.h",
      "vnmsub_vx.h",
      "vsaddu_vv.h",
      "vssrl_vx.h",
      "vwmul_vx.h",
      "amomaxu_d.h",
      "c_fsw.h",
      "fclass_q.h",
      "feq_d.h",
      "fsd.h",
      "ori.h",
      "vadc_vvm.h",
      "vfmin_vf.h",
      "vfsqrt_v.h",
      "vmerge_vxm.h",
      "vmsltu_vx.h",
      "vnsra_wi.h",
      "vsaddu_vx.h",
      "vssubu_vv.h",
      "vwredsumu_vs.h",
      "amomaxu_w.h",
      "c_fswsp.h",
      "fclass_s.h",
      "feq_q.h",
      "fsgnj_d.h",
      "rem.h",
      "vadc_vxm.h",
      "vfmin_vv.h",
      "vfsub_vf.h",
      "vmfeq_vf.h",
      "vmslt_vv.h",
      "vnsra_wv.h",
      "vsadd_vi.h",
      "vssubu_vx.h",
      "vwredsum_vs.h",
      "amomax_w.h",
      "c_jal.h",
      "fcvt_d_l.h",
      "feq_s.h",
      "fsgnjn_d.h",
      "remu.h",
      "vadd_vi.h",
      "vfmsac_vf.h",
      "vfsub_vv.h",
      "vmfeq_vv.h",
      "vmslt_vx.h",
      "vnsra_wx.h",
      "vsadd_vv.h",
      "vssub_vv.h",
      "vwsubu_vv.h",
      "amomin_d.h",
      "c_jalr.h",
      "fcvt_d_lu.h",
      "fld.h",
      "fsgnjn_q.h",
      "remuw.h",
      "vadd_vv.h",
      "vfmsac_vv.h",
      "vfwadd_vf.h",
      "vmfge_vf.h",
      "vmsne_vi.h",
      "vnsrl_wi.h",
      "vsadd_vx.h",
      "vssub_vx.h",
      "vwsubu_vx.h",
      "amominu_d.h",
      "c_j.h",
      "fcvt_d_q.h",
      "fle_d.h",
      "fsgnjn_s.h",
      "remw.h",
      "vadd_vx.h",
      "vfmsub_vf.h",
      "vfwadd_vv.h",
      "vmfgt_vf.h",
      "vmsne_vv.h",
      "vnsrl_wv.h",
      "vsbc_vvm.h",
      "vwsubu_wv.h",
      "amominu_w.h",
      "c_jr.h",
      "fcvt_d_s.h",
      "fle_q.h",
      "fsgnj_q.h",
      "sb.h",
      "vand_vi.h",
      "vfmsub_vv.h",
      "vfwadd_wf.h",
      "vmfle_vf.h",
      "vmsne_vx.h",
      "vnsrl_wx.h",
      "vsbc_vxm.h",
      "vsub_vv.h",
      "vwsubu_wx.h",
      "amomin_w.h",
      "c_li.h",
      "fcvt_d_w.h",
      "fle_s.h",
      "fsgnj_s.h",
      "sc_d.h",
      "vand_vv.h",
      "vfmul_vf.h",
      "vfwadd_wv.h",
      "vmfle_vv.h",
      "vmsof_m.h",
      "vor_vi.h",
      "vsub_vx.h",
      "vwsub_vv.h",
      "amoor_d.h",
      "c_lui.h",
      "amoor_d.h",
      "c_lui.h",
      "fcvt_d_wu.h",
      "flq.h",
      "fsgnjx_d.h",
      "sc_w.h",
      "vand_vx.h",
      "vfmul_vv.h",
      "vfwcvt_f_f_v.h",
      "vmflt_vf.h",
      "vmulhsu_vv.h",
      "vor_vv.h",
      "vsetvl.h",
      "vwsub_vx.h",
      "amoor_w.h",
      "c_lw.h",
      "fcvt_l_d.h",
      "flt_d.h",
      "fsgnjx_q.h",
      "sd.h",
      "vasubu_vv.h",
      "vfmv_f_s.h",
      "vfwcvt_f_xu_v.h",
      "vmflt_vv.h",
      "vmulhsu_vx.h",
      "vor_vx.h",
      "vsetvli.h",
      "vwsub_wv.h",
      "amoswap_d.h",
      "c_lwsp.h",
      "fcvt_l_q.h",
      "flt_q.h",
      "fsgnjx_s.h",
      "sfence_vma.h",
      "vasubu_vx.h",
      "vfmv_s_f.h",
      "vfwcvt_f_x_v.h",
      "vmfne_vf.h",
      "vmulhu_vv.h",
      "vpopc_m.h",
      "vwsub_wx.h",
      "amoswap_w.h",
      "c_mv.h",
      "fcvt_l_s.h",
      "flt_s.h",
      "fsq.h",
      "sh.h",
      "vasub_vv.h",
      "vfmv_v_f.h",
      "vfwcvt_x_f_v.h",
      "vmfne_vv.h",
      "vmulhu_vx.h",
      "vqmaccsu_vv.h",
      "vxor_vi.h",
      "amoxor_d.h",
      "c_or.h",
      "fcvt_lu_d.h",
      "flw.h",
      "fsqrt_d.h",
      "sll.h",
      "vasub_vx.h",
      "vfncvt_f_f_w.h",
      "vfwcvt_xu_f_v.h",
      "vminu_vv.h",
      "vmulh_vv.h",
      "vqmaccsu_vx.h",
      "vslide1down_vx.h",
      "vxor_vv.h",
      "amoxor_w.h",
      "c_slli.h",
      "fcvt_lu_q.h",
      "fmadd_d.h",
      "fsqrt_q.h",
      "slli.h",
      "vcompress_vm.h",
      "vfncvt_f_xu_w.h",
      "vfwmacc_vf.h",
      "vminu_vx.h",
      "vmulh_vx.h",
      "vqmaccus_vx.h",
      "vslide1up_vx.h",
      "vxor_vx.h",
      "and.h",
      "c_srai.h",
      "fcvt_lu_s.h",
      "fmadd_q.h",
      "fsqrt_s.h",
      "slliw.h",
      "vdivu_vv.h",
      "vfncvt_f_x_w.h",
      "vfwmacc_vv.h",
      "vmin_vv.h",
      "vmul_vv.h",
      "vqmaccu_vv.h",
      "vslidedown_vi.h",
      "wfi.h",
      "andi.h",
      "c_srli.h",
      "fcvt_q_d.h",
      "fmadd_s.h",
      "fsub_d.h",
      "sllw.h",
      "vdivu_vx.h",
      "vfncvt_rod_f_f_w.h",
      "vfwmsac_vf.h",
      "vmin_vx.h",
      "vmul_vx.h",
      "vqmaccu_vx.h",
      "vslidedown_vx.h",
      "xor.h",
      "auipc.h",
      "csrrc.h",
      "fcvt_q_l.h",
      "fmax_d.h",
      "fsub_q.h",
      "slt.h",
      "vdiv_vv.h",
      "vfncvt_x_f_w.h",
      "vfwmsac_vv.h",
      "vmnand_mm.h",
      "vmv1r_v.h",
      "vqmacc_vv.h",
      "vslideup_vi.h",
      "xori.h",
      "beq.h",
      "csrrci.h",
      "fcvt_q_lu.h",
      "fmax_q.h",
      "fsub_s.h",
      "slti.h",
      "vdiv_vx.h",
      "vfncvt_xu_f_w.h",
      "vfwmul_vf.h",
      "vmnor_mm.h",
      "vmv2r_v.h",
      "vqmacc_vx.h",
      "vslideup_vx.h",
      "vwaddu_vv.h",
      "bge.h",
      "csrrs.h",
      "fcvt_q_s.h",
      "fmax_s.h",
      "fsw.h",
      "sltiu.h",
      "vdotu_vv.h",
      "vfnmacc_vf.h",
      "vfwmul_vv.h",
      "vmor_mm.h",
      "vmv4r_v.h",
      "vredand_vs.h",
      "vsll_vi.h",
      "vwaddu_vx.h",
      "bgeu.h",
      "csrrsi.h",
      "fcvt_q_w.h",
      "fmin_d.h",
      "jal.h",
      "sltu.h",
      "vdot_vv.h",
      "vfnmacc_vv.h",
      "vfwnmacc_vf.h",
      "vmornot_mm.h",
      "vmv8r_v.h",
      "vredmaxu_vs.h",
      "vsll_vv.h",
      "vwaddu_wv.h",
      "blt.h",
      "csrrw.h",
      "fcvt_q_wu.h",
      "fmin_q.h",
      "jalr.h",
      "sra.h",
      "vfadd_vf.h",
      "vfnmadd_vf.h",
      "vfwnmacc_vv.h",
      "vmsbc_vvm.h",
      "vmvnfr_v.h",
      "vredmax_vs.h",
      "vsll_vx.h",
      "vwaddu_wx.h",
      "bltu.h",
      "csrrwi.h",
      "fcvt_s_d.h",
      "fmin_s.h",
      "lb.h",
      "srai.h",
      "vfadd_vv.h",
      "vfnmadd_vv.h",
      "vfwnmsac_vf.h",
      "vmsbc_vxm.h",
      "vmv_s_x.h",
      "vredminu_vs.h",
      "vsmul_vv.h",
      "vwadd_vv.h",
      "bne.h",
      "c_sub.h",
      "fcvt_s_l.h",
      "fmsub_d.h",
      "lbu.h",
      "sraiw.h",
      "vfclass_v.h",
      "vfnmsac_vf.h",
      "vfwnmsac_vv.h",
      "vmsbf_m.h",
      "vmv_v_i.h",
      "vredmin_vs.h",
      "vsmul_vx.h",
      "vwadd_vx.h",
      "c_add.h",
      "c_subw.h",
      "fcvt_s_lu.h",
      "fmsub_q.h",
      "ld.h",
      "sraw.h",
      "vfcvt_f_xu_v.h",
      "vfnmsac_vv.h",
      "vfwredosum_vs.h",
      "vmacc_vv.h",
      "vmseq_vi.h",
      "vmv_v_v.h",
      "vredor_vs.h",
      "vsra_vi.h",
      "vwadd_wv.h",
      "c_addi4spn.h",
      "c_sw.h",
      "fcvt_s_q.h",
      "fmsub_s.h",
      "lh.h",
      "sret.h",
      "vfcvt_f_x_v.h",
      "vfnmsub_vf.h",
      "vfwredsum_vs.h",
      "vmacc_vx.h",
      "vmseq_vv.h",
      "vmv_v_x.h",
      "vredsum_vs.h",
      "vsra_vv.h",
      "vwadd_wx.h",
      "c_addi.h",
      "c_swsp.h",
      "fcvt_s_w.h",
      "fmul_d.h",
      "lhu.h",
      "srl.h",
      "vfcvt_x_f_v.h",
      "vfnmsub_vv.h",
      "vfwsub_vf.h",
      "vmadc_vim.h",
      "vmseq_vx.h",
      "vmv_x_s.h",
      "vredxor_vs.h",
      "vsra_vx.h",
      "vwmaccsu_vv.h",
      "c_addw.h",
      "c_xor.h",
      "fcvt_s_wu.h",
      "fmul_q.h",
      "lr_d.h",
      "srli.h",
      "vfcvt_xu_f_v.h",
      "vfrdiv_vf.h",
      "vfwsub_vv.h",
      "vmadc_vvm.h",
      "vmsgtu_vi.h",
      "vmxnor_mm.h",
      "vremu_vv.h",
      "vsrl_vi.h",
      "vwmaccsu_vx.h",
      "c_and.h",
      "div.h",
      "fcvt_w_d.h",
      "fmul_s.h",
      "lr_w.h",
      "srliw.h",
      "vfdiv_vf.h",
      "vfredmax_vs.h",
      "vfwsub_wf.h",
      "vmadc_vxm.h",
      "vmsgtu_vx.h",
      "vmxor_mm.h",
      "vremu_vx.h",
      "vsrl_vv.h",
      "vwmaccus_vx.h",
      "c_andi.h",
      "divu.h",
      "fcvt_w_q.h",
      "fmv_d_x.h",
      "lui.h",
      "srlw.h",
      "vfdiv_vv.h",
      "vfredmin_vs.h",
      "vfwsub_wv.h",
      "vmadd_vv.h",
      "vmsgt_vi.h",
      "vnclipu_wi.h",
      "vrem_vv.h",
      "vsrl_vx.h",
      "vwmaccu_vv.h",
  ]
  
  SOFTFLOAT_SOURCE_FILENAMES = [
      "f16_to_ui8.c",
      "f16_to_ui16.c",
      "f32_to_i16.c",
      "f16_to_i8.c",
      "f16_to_i16.c",
      "f128_add.c",
      "f16_div.c",
      "f32_eq.c",
      "f64_eq_signaling.c",
      "i64_to_f128.c",
      "s_f128UIToCommonNaN.c",
      "s_propagateNaNF16UI.c",
      "s_shortShiftRight128.c",
      "f128_classify.c",
      "f16_classify.c",
      "f16_eq.c",
      "f32_eq_signaling.c",
      "f64_isSignalingNaN.c",
      "i64_to_f16.c",
      "s_f16UIToCommonNaN.c",
      "s_propagateNaNF32UI.c",
      "s_shortShiftRightExtendM.c",
      "f128_div.c",
      "f16_eq_signaling.c",
      "f32_isSignalingNaN.c",
      "f64_le.c",
      "i64_to_f32.c",
      "s_f32UIToCommonNaN.c",
      "s_propagateNaNF64UI.c",
      "s_shortShiftRightJam128.c",
      "f128_eq.c",
      "f16_isSignalingNaN.c",
      "f32_le.c",
      "f64_le_quiet.c",
      "i64_to_f64.c",
      "s_f64UIToCommonNaN.c",
      "s_remStepMBy32.c",
      "s_shortShiftRightJam128Extra.c",
      "f128_eq_signaling.c",
      "f16_le.c",
      "f32_le_quiet.c",
      "f64_lt.c",
      "s_add128.c",
      "s_le128.c",
      "s_roundMToI64.c",
      "s_shortShiftRightJam64.c",
      "f128_isSignalingNaN.c",
      "f16_le_quiet.c",
      "f32_lt.c",
      "f64_lt_quiet.c",
      "s_add256M.c",
      "s_lt128.c",
      "s_roundMToUI64.c",
      "s_shortShiftRightJam64Extra.c",
      "f128_le.c",
      "f16_lt.c",
      "f32_lt_quiet.c",
      "f64_mulAdd.c",
      "s_addCarryM.c",
      "s_mul128By32.c",
      "s_roundPackMToI64.c",
      "s_shortShiftRightM.c",
      "f128_le_quiet.c",
      "f16_lt_quiet.c",
      "f32_mulAdd.c",
      "f64_mul.c",
      "s_addComplCarryM.c",
      "s_mul128MTo256M.c",
      "s_roundPackMToUI64.c",
      "s_sub128.c",
      "f128_lt.c",
      "f16_mulAdd.c",
      "f32_mul.c",
      "f64_rem.c",
      "s_addMagsF128.c",
      "s_mul128To256M.c",
      "s_roundPackToF128.c",
      "s_sub1XM.c",
      "f128_lt_quiet.c",
      "f16_mul.c",
      "f32_rem.c",
      "f64_roundToInt.c",
      "s_addMagsF16.c",
      "s_mul64ByShifted32To128.c",
      "s_roundPackToF16.c",
      "s_sub256M.c",
      "f128_mulAdd.c",
      "f16_rem.c",
      "f32_roundToInt.c",
      "f64_sqrt.c",
      "s_addMagsF32.c",
      "s_mul64To128.c",
      "s_roundPackToF32.c",
      "s_subMagsF128.c",
      "f128_mul.c",
      "f16_roundToInt.c",
      "f32_sqrt.c",
      "f64_sub.c",
      "s_addMagsF64.c",
      "s_mul64To128M.c",
      "s_roundPackToF64.c",
      "s_subMagsF16.c",
      "f128_rem.c",
      "f16_sqrt.c",
      "f32_sub.c",
      "f64_to_f128.c",
      "s_addM.c",
      "s_mulAddF128.c",
      "s_roundPackToI32.c",
      "s_subMagsF32.c",
      "f128_roundToInt.c",
      "f16_sub.c",
      "f32_to_f128.c",
      "f64_to_f16.c",
      "s_approxRecip_1Ks.c",
      "s_mulAddF16.c",
      "s_roundPackToI64.c",
      "s_subMagsF64.c",
      "f128_sqrt.c",
      "f16_to_f128.c",
      "f32_to_f16.c",
      "f64_to_f32.c",
      "s_approxRecip32_1.c",
      "s_mulAddF32.c",
      "s_roundPackToUI32.c",
      "s_subM.c",
      "f128_sub.c",
      "f16_to_f32.c",
      "f32_to_f64.c",
      "f64_to_i32.c",
      "s_approxRecipSqrt_1Ks.c",
      "s_mulAddF64.c",
      "s_roundPackToUI64.c",
      "ui32_to_f128.c",
      "f128_to_f16.c",
      "f16_to_f64.c",
      "f32_to_i32.c",
      "f64_to_i32_r_minMag.c",
      "s_approxRecipSqrt32_1.c",
      "s_negXM.c",
      "s_roundToI32.c",
      "ui32_to_f16.c",
      "f128_to_f32.c",
      "f16_to_i32.c",
      "f32_to_i32_r_minMag.c",
      "f64_to_i64.c",
      "s_commonNaNToF128UI.c",
      "s_normRoundPackToF128.c",
      "s_roundToI64.c",
      "ui32_to_f32.c",
      "f128_to_f64.c",
      "f16_to_i32_r_minMag.c",
      "f32_to_i64.c",
      "f64_to_i64_r_minMag.c",
      "s_commonNaNToF16UI.c",
      "s_normRoundPackToF16.c",
      "s_roundToUI32.c",
      "ui32_to_f64.c",
      "f128_to_i32.c",
      "f16_to_i64.c",
      "f32_to_i64_r_minMag.c",
      "f64_to_ui32.c",
      "s_commonNaNToF32UI.c",
      "s_normRoundPackToF32.c",
      "s_roundToUI64.c",
      "ui64_to_f128.c",
      "f32_to_ui16.c",
      "f128_to_i32_r_minMag.c",
      "f16_to_i64_r_minMag.c",
      "f32_to_ui32.c",
      "f64_to_ui32_r_minMag.c",
      "s_commonNaNToF64UI.c",
      "s_normRoundPackToF64.c",
      "s_shiftRightJam128.c",
      "ui64_to_f16.c",
      "f128_to_i64.c",
      "f16_to_ui32.c",
      "f32_to_ui32_r_minMag.c",
      "f64_to_ui64.c",
      "s_compare128M.c",
      "s_normSubnormalF128Sig.c",
      "s_shiftRightJam128Extra.c",
      "ui64_to_f32.c",
      "f128_to_i64_r_minMag.c",
      "f16_to_ui32_r_minMag.c",
      "f32_to_ui64.c",
      "f64_to_ui64_r_minMag.c",
      "s_compare96M.c",
      "s_normSubnormalF16Sig.c",
      "s_shiftRightJam256M.c",
      "ui64_to_f64.c",
      "f128_to_ui32.c",
      "f16_to_ui64.c",
      "f32_to_ui64_r_minMag.c",
      "fall_maxmin.c",
      "s_countLeadingZeros16.c",
      "s_normSubnormalF32Sig.c",
      "s_shiftRightJam32.c",
      "f128_to_ui32_r_minMag.c",
      "f16_to_ui64_r_minMag.c",
      "f64_add.c",
      "i32_to_f128.c",
      "s_countLeadingZeros32.c",
      "s_normSubnormalF64Sig.c",
      "s_shiftRightJam64.c",
      "f128_to_ui64.c",
      "f32_add.c",
      "f64_classify.c",
      "i32_to_f16.c",
      "s_countLeadingZeros64.c",
      "softfloat_raiseFlags.c",
      "s_shiftRightJam64Extra.c",
      "f128_to_ui64_r_minMag.c",
      "f32_classify.c",
      "f64_div.c",
      "i32_to_f32.c",
      "s_countLeadingZeros8.c",
      "softfloat_state.c",
      "s_shortShiftLeft128.c",
      "f16_add.c",
      "f32_div.c",
      "f64_eq.c",
      "i32_to_f64.c",
      "s_eq128.c",
      "s_propagateNaNF128UI.c",
      "s_shortShiftLeft64To96M.c",
  ]  # These are all to be renamed as cc files during copying
  
  SOFTFLOAT_HEADER_FILENAMES = [
      "internals.h",
      "platform.h",
      "primitiveTypes.h",
      "softfloat_types.h",
  ]
  SPIKE_SOURCE_FILENAMES = [
      "fesvr/option_parser.cc",
      "riscv/cachesim.cc",
      "riscv/execute.cc",
      "riscv/extension.cc",
      "riscv/trap.cc",
      "riscv/extensions.cc",
  ]
  SPIKE_HEADER_FILENAMES = [
      "fesvr/option_parser.h",
      "fesvr/elf.h",
      "riscv/arith.h",
      "riscv/cachesim.h",
      "riscv/common.h",
      "riscv/encoding.h",
      "riscv/mmu.h",
      "riscv/opcodes.h",
      "riscv/simif.h",
      "riscv/trap.h",
      "riscv/tracer.h",
      "riscv/insn_template.h",
      "riscv/extension.h",
      "riscv/memtracer.h",
      "riscv/byteorder.h",
      "insn_list.h",
      "icache.h",
  ]
  
  # All these ones need to be turned into patch operations rather than file
  # replacements to the extent possible
  REPLACEMENT_SOURCE_FILENAMES = [
      "mmu.cc",
      "simlib.cc",
      "processor.cc",
      "execute.cc",
      "regnames.cc",
      "disasm.cc",
  ]
  REPLACEMENT_HEADER_FILENAMES = [
      "config.h",
      "mmu.h",
      "simif.h",
      "simlib.h",
      "specialize.h",
      "primitives.h",
      "processor.h",
      "devices.h",
      "decode.h",
      "disasm.h",
  ]
  REPLACEMENT_INSTRUCTION_HEADER_FILENAMES = ["mret.h", "sret.h"]
  GLOB_REPLACEMENT_INSTRUCTION_HEADER_FILENAMES = ["insns/*.h"]
  
  if NOISY:
      print(
          "###\n### Copying original Spike files and then modifying them. "
          "Output will be in src and inc directories.\n###"
      )
  
  
  def makedir(path):
      try:
          os.mkdir(path)
      except OSError as exc:
          if (exc.errno != errno.EEXIST) or (not os.path.isdir(path)):
              raise
  
  
  def is_first_file_newer(file1, file2):
      """If file2 is older than file1, or does not exist, return True"""
      return True
  
  
  def copy(src, dest):
      if is_first_file_newer(src, dest):
          print("Copying %s to %s" % (src, dest))
          shutil.copy2(src, dest)
      else:
          print("dest file %s not older than src file %s" % (dest, src))
  
  
  def copy_files(prefix_path_string, filenames_list, destination_directory):
      if NOISY:
          print(
              "Copying specific files from: "
              + prefix_path_string
              + " to destination directory: "
              + destination_directory
          )
  
      for filename in filenames_list:
          # Take all the c code and label it as c++ code
          if ".cc" not in str(filename) and ".h" not in str(filename):
              copy(
                  prefix_path_string + "/" + filename,
                  destination_directory + "/" + os.path.basename(filename) + "c",
              )
          else:
              copy(prefix_path_string + "/" + filename, destination_directory)
  
  
  copy_files(ORIGINAL_SOURCE_DIRECTORY, SPIKE_SOURCE_FILENAMES, "./src")
  copy_files(ORIGINAL_SOURCE_DIRECTORY, SPIKE_HEADER_FILENAMES, "./inc")
  copy_files(
      ORIGINAL_INSTRUCTIONS_DIRECTORY, INSTRUCTION_SOURCE_FILENAMES, "./src"
  )
  copy_files(ORIGINAL_SOFTFLOAT_DIRECTORY, SOFTFLOAT_SOURCE_FILENAMES, "./src")
  copy_files(ORIGINAL_SOFTFLOAT_DIRECTORY, SOFTFLOAT_HEADER_FILENAMES, "./inc")
  copy_files(REPLACEMENTS_DIRECTORY, REPLACEMENT_SOURCE_FILENAMES, "./src")
  copy_files(REPLACEMENTS_DIRECTORY, REPLACEMENT_HEADER_FILENAMES, "./inc")
  
  makedir("./inc/insns")
  copy_files(
      ORIGINAL_INSTRUCTION_HEADERS_DIRECTORY,
      INSTRUCTION_HEADER_FILENAMES,
      "./inc/insns",
  )
  copy_files(
      REPLACEMENTS_DIRECTORY,
      REPLACEMENT_INSTRUCTION_HEADER_FILENAMES,
      "./inc/insns",
  )
  
  for f in glob.glob(
      str(
          REPLACEMENTS_DIRECTORY
          + "/"
          + GLOB_REPLACEMENT_INSTRUCTION_HEADER_FILENAMES[0]
      )
  ):
      copy(f, "./inc/insns")
  
  makedir("./inc/fesvr")
  copy("inc/option_parser.h", "inc/fesvr/option_parser.h")
  