Skip to content

Commit

Permalink
offset to index methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanohar committed Dec 23, 2020
1 parent 8528498 commit a75aa48
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions passes/state/statepass.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,32 @@ class ActStatePass : public ActPass {

chp_offsets getGlobals() { return _globals; }

int isGlobalOffset (int off) {
if (off >= 0) { return 0; }
off = -off;
if (off & 1) { return 0; }
return 1;
}

int isPortOffset (int off) {
if (off >= 0) { return 0; }
off = -off;
if (off & 1) { return 1; }
return 0;
}

int portIdx (int off) {
Assert (isPortOffset (off), "What?");
off = -off;
return (off + 1)/2 - 1;
}

int globalIdx (int off) {
Assert (isGlobalOffset (off), "What?");
off = -off;
return off/2 - 1;
}

private:
void *local_op (Process *p, int mode = 0);
void free_local (void *);
Expand Down

0 comments on commit a75aa48

Please sign in to comment.