#ifndef _BLOCKS_H #define _BLOCKS_H #define STACK_MACHINE #include "c.h" #include "collections.h" #include "x_stack.h" #define NODE_SIZE(p) (roundup(opsize(p->op), IR->ptrmetric.size) / IR->ptrmetric.size) typedef struct block* Block; /** Initialises the def and use sets for block b */ void block_initDefUse(Block b); /** Returns the first node of block b */ Node block_firstNode(Block b); /** Returns the last node of block b */ Node block_lastNode(Block b); /** Returns the id of block b */ int block_id(Block b); /** Sets the id of block b */ void block_setID(Block b, int id); /** Sets the e-stack (includes p-stack) depth at the start of block b */ void block_setStartEDepth(Block b, int depth); /** Returns the e-stack (includes p-stack) depth at the start of block b */ int block_getStartEDepth(Block b); /** Sets the l-stack depth at the start of block b */ void block_setStartLDepth(Block b, int depth); /** Returns the l-stack depth at the start of block b */ int block_getStartLDepth(Block b); /** Sets the e-stack depth at the end of block b */ void block_setEndEDepth(Block b, int depth); /** Returns the e-stack depth at the end of block b */ int block_getEndEDepth(Block b); void block_setEndLDepth(Block b, int depth); int block_getEndLDepth(Block b); /** Creates a new block starting with first, ending with last */ Block block_new(int startDepth, int endDepth, Node first, Node last); /** Deletes a variable (STACK or VREG) from chain. * Need to called for any variables in a tree that is removed * or linkages will be corrupted */ void block_deleteVariable(Block b, Node temp); /** Returns the BitSet representing the local variables block_def in block b. */ BitSet block_def(Block b); /** Returns the BitSet representing the local variables block_use in block b. */ BitSet block_use(Block b); /** Returns the BitSet representing the local variables live incoming to block b. */ BitSet block_livein(Block b); /** Returns the BitSet representing the local variables live outgoing from block b. */ BitSet block_liveout(Block b); /** Creates a new block consisting of block b1 followed by b2. */ Block block_merge(Block b1, Block b2); /** Returns the length of block b */ int block_length(Block b); /** Prints a textula representation of block b to out */ void block_print(Block b, FILE* out); Node block_firstTemp(Block b); Node block_lastTemp(Block b); /** Returns the BitSet representing the local variables rejected by this block. */ BitSet block_reject(Block b); XStack block_inStack(Block b); XStack block_outStack(Block b); /** Inserts the forest of nodes at the beginning of block b */ void block_insertAtHead(Block b, Node forest); /** Inserts the forest of nodes at the end of block b, but before any final * branch. */ void block_insertAtTail(Block b, Node forest); void block_setInStack(Block b, XStack in); void block_setOutStack(Block b, XStack out); /** Increases the l-stack depth of all VREG, STACK and COPY nodes from * * first to last inclusive. */ void increaseLDepth(Node first, Node node); #endif