class CodeGen: '''The code generator for the AST classes''' def __init__(self, language='C'): '''Instantiates a code generator''' self.generator = None if language.lower() in ['c','c++','cxx']: self.generator = CodeGen_C() elif language.lower() in ['f', 'f90', 'fortran']: self.generator = CodeGen_F() elif language.lower() in ['cuda']: from orio.module.loop.codegen_cuda import CodeGen_CUDA self.generator = CodeGen_CUDA() elif language.lower() in ['opencl']: from orio.module.loop.codegen_opencl import CodeGen_OpenCL self.generator = CodeGen_OpenCL() else: g.err('orio.module.loop.codegen: Unknown language specified for code generation: %s' % language) pass #---------------------------------------------- def generate(self, tnode, indent = ' ', extra_indent = ' '): '''Generates code that corresponds to the given AST''' return self.generator.generate(tnode,indent,extra_indent)
class CodeGen: '''The code generator for the AST classes''' def __init__(self, language='C'): '''Instantiates a code generator''' self.generator = None if language.lower() in ['c', 'c++', 'cxx']: self.generator = CodeGen_C() elif language.lower() in ['f', 'f90', 'fortran']: self.generator = CodeGen_F() elif language.lower() in ['cuda']: from orio.module.loop.codegen_cuda import CodeGen_CUDA self.generator = CodeGen_CUDA() elif language.lower() in ['opencl']: from orio.module.loop.codegen_opencl import CodeGen_OpenCL self.generator = CodeGen_OpenCL() else: g.err( 'orio.module.loop.codegen: Unknown language specified for code generation: %s' % language) pass #---------------------------------------------- def generate(self, tnode, indent=' ', extra_indent=' '): '''Generates code that corresponds to the given AST''' return self.generator.generate(tnode, indent, extra_indent)
def __init__(self, language='C'): '''Instantiates a code generator''' self.generator = None if language.lower() in ['c','c++','cxx']: self.generator = CodeGen_C() elif language.lower() in ['f', 'f90', 'fortran']: self.generator = CodeGen_F() elif language.lower() in ['cuda']: from orio.module.loop.codegen_cuda import CodeGen_CUDA self.generator = CodeGen_CUDA() elif language.lower() in ['opencl']: from orio.module.loop.codegen_opencl import CodeGen_OpenCL self.generator = CodeGen_OpenCL() else: g.err('orio.module.loop.codegen: Unknown language specified for code generation: %s' % language) pass
def __init__(self, language='C'): '''Instantiates a code generator''' self.generator = None if language.lower() in ['c', 'c++', 'cxx']: self.generator = CodeGen_C() elif language.lower() in ['f', 'f90', 'fortran']: self.generator = CodeGen_F() elif language.lower() in ['cuda']: from orio.module.loop.codegen_cuda import CodeGen_CUDA self.generator = CodeGen_CUDA() elif language.lower() in ['opencl']: from orio.module.loop.codegen_opencl import CodeGen_OpenCL self.generator = CodeGen_OpenCL() else: g.err( 'orio.module.loop.codegen: Unknown language specified for code generation: %s' % language) pass