/bcd.py
/bitmanip.py
/branch.py
+/butterfly.py
/comparefixed.py
/condition.py
/fixedarith.py
# 30 August 2006 / Cape Town, South Africa
# Modifications for inclusion in PLY distribution
-import sys
+import os
from pprint import pprint
from copy import copy
from ply import lex, yacc
return astor.to_source(tree), regsused
+def check_in_gitignore(output_file):
+ gitignore_file = os.path.join(os.path.dirname(output_file), ".gitignore")
+ base_name = os.path.basename(output_file)
+ with open(gitignore_file, "r") as f:
+ for l in f.readlines():
+ l = l.strip()
+ if "/" + base_name == l:
+ return
+ if l == "*.py":
+ if base_name.endswith(".py"):
+ return
+ raise ValueError(f"generated output file not in .gitignore:\n"
+ f"output file: {output_file}\n"
+ f".gitignore file: {gitignore_file}")
+
+
def test():
gsc = GardenSnakeCompiler(debug=True)
import shutil
import subprocess
from openpower.decoder.pseudo.functionreader import ISAFunctions, get_isafn_dir
-from openpower.decoder.power_pseudo import convert_to_pure_python
+from openpower.decoder.power_pseudo import (convert_to_pure_python,
+ check_in_gitignore)
def get_isafn_src_dir():
os.makedirs(isadir, exist_ok=True)
fname = os.path.join(isadir, "%s.py" % pagename)
sourcecache = dict()
+ check_in_gitignore(fname)
with open(fname, "w") as f:
f.write(header % function['desc']) # write out header
# go through all instructions
import shutil
import subprocess
from openpower.decoder.pseudo.pagereader import ISA, get_isa_dir
-from openpower.decoder.power_pseudo import convert_to_python
+from openpower.decoder.power_pseudo import (convert_to_python,
+ check_in_gitignore)
from openpower.decoder.orderedset import OrderedSet
from openpower.decoder.isa.caller import create_args
instrs = self.page[pagename]
isadir = get_isasrc_dir()
fname = os.path.join(isadir, "%s.py" % pagename)
+ check_in_gitignore(fname)
with open(fname, "w") as f:
iinf = ''
# write headers: FP gets extra imports
def write_isa_class(self):
isadir = get_isasrc_dir()
fname = os.path.join(isadir, "all.py")
-
+ check_in_gitignore(fname)
with open(fname, "w") as f:
f.write('# auto-generated by pywriter.py: do not edit or commit\n')
f.write('from openpower.decoder.isa.caller import ISACaller\n')