CStuff

public final class CStuff

C language specific methods.

Methods

buildAllocate

protected static Tree buildAllocate(Tree mallocTree, int typeSize, SymbolTable symbolTable, Instruction instruction)

Builds a transformed copy of the C-syntax mallocTree, using the IL syntax op_allocate

Parameters
  • mallocTree – a call to malloc or calloc, possibly enclosed into a cast.

Returns

an op_allocate tree, containing in particular the cast type if present.

buildDeallocate

protected static Tree buildDeallocate(Tree callFreeTree)

buildIOCall

protected static Tree buildIOCall(Tree callTree)

buildMalloc

public static Tree buildMalloc(Tree allocateTree, Tree assigned)

Builds a transformed copy of the IL syntax op_allocate, as a C-syntax mallocTree. Decision of the C-style allocation (malloc, calloc, or cudaMalloc) is based the “sourcetree” annotation of the allocateTree.

Parameters
  • allocateTree – an op_allocate tree a call to malloc or calloc, possibly enclosed into a cast.

  • assigned – the variable that receives the allocated memory. Used only when regenerating a cudaMalloc.

Returns

a call to malloc or calloc, possibly enclosed into a cast, or a call to cudaMalloc

buildPow

protected static Tree buildPow(Tree callPowTree)

initCSymbolTable

public static void initCSymbolTable(SymbolTable symbolTable)

Inserts predefined C stuff into this initial symbolTable.

isAFree

protected static boolean isAFree(Tree callTree)

isAMalloc

protected static boolean isAMalloc(Tree mallocTree)

isAPow

protected static boolean isAPow(SymbolTable symbolTable, Tree callTree)

isAnIoCall

public static boolean isAnIoCall(Tree callTree)

isaModifiedFloatFloat

protected static boolean isaModifiedFloatFloat(Tree instrOrExpr)

Tests that instrOrExpr is op_modifiedType(op_list[op_ident:”float”], float()) [llh 4Sept2017] This is only because of a bug? introduced by version 6119 that creates “float real”s in C instead of plain “float”s.