src/codegen.c
char *
pickLoadInst(Type *type) {
  switch (type->type) {
    case TYP_S8:
      return "loadsb";
    case TYP_U8:
      return "loadub";
    case TYP_S16:
      return "loadsh";
    case TYP_U16:
      return "loaduh";
    case TYP_S32:
      return "loadsw";
    case TYP_U32:
    case TYP_BOOL:
    case TYP_CHAR:
      return "loaduw";
    case TYP_S64:
    case TYP_U64:
    case TYP_PTR:
    case TYP_FUN:
      return "loadl";
    case TYP_BINDING:
      return pickLoadInst(type->typeEntry->data);
    case TYP_VOID:
    case TYP_INTLIT:
    case TYP_RECORD:
    case TYP_ARRAY:
      assert(false);
      return NULL;
  }
  return NULL;
}
/* Picks the correct load instruction for a given type. This is needed because
 * if a item smaller than the size of the temporary is loaded, a bitshift is
 * needed, and this varies depending on if the type is signed */
Picks the correct load instruction for a given type. This is needed because
if a item smaller than the size of the temporary is loaded, a bitshift is
needed, and this varies depending on if the type is signed
Picks the correct load instruction for a given type . This is needed because if a item smaller than the size of the temporary is loaded a bitshift is needed and this varies depending on if the type is signed
char *
pickLoadInst(Type *type) {
  switch (type->type) {
    case TYP_S8:
      return "loadsb";
    case TYP_U8:
      return "loadub";
    case TYP_S16:
      return "loadsh";
    case TYP_U16:
      return "loaduh";
    case TYP_S32:
      return "loadsw";
    case TYP_U32:
    case TYP_BOOL:
    case TYP_CHAR:
      return "loaduw";
    case TYP_S64:
    case TYP_U64:
    case TYP_PTR:
    case TYP_FUN:
      return "loadl";
    case TYP_BINDING:
      return pickLoadInst(type->typeEntry->data);
    case TYP_VOID:
    case TYP_INTLIT:
    case TYP_RECORD:
    case TYP_ARRAY:
      assert(false);
      return NULL;
  }
  return NULL;
}
char * pickLoadInst ( Type * type ) { switch ( type -> type ) { case TYP_S8 : return " " ; case TYP_U8 : return " " ; case TYP_S16 : return " " ; case TYP_U16 : return " " ; case TYP_S32 : return " " ; case TYP_U32 : case TYP_BOOL : case TYP_CHAR : return " " ; case TYP_S64 : case TYP_U64 : case TYP_PTR : case TYP_FUN : return " " ; case TYP_BINDING : return pickLoadInst ( type -> typeEntry -> data ) ; case TYP_VOID : case TYP_INTLIT : case TYP_RECORD : case TYP_ARRAY : assert ( false ) ; return NULL ; } return NULL ; }
Picks the correct load instruction for a given type.
Picks the correct load instruction for a given type .