mirror of https://git.wuffs.org/MWCC
79 lines
1.7 KiB
C
79 lines
1.7 KiB
C
|
#include "compiler/Switch.h"
|
||
|
#include "compiler/CError.h"
|
||
|
#include "compiler/CFunc.h"
|
||
|
#include "compiler/CInt64.h"
|
||
|
#include "compiler/objects.h"
|
||
|
#include "compiler/CParser.h"
|
||
|
#include "compiler/PCode.h"
|
||
|
|
||
|
ObjectList *switchtables;
|
||
|
static void *caselabels;
|
||
|
static void *caseranges;
|
||
|
static SInt32 ncases;
|
||
|
static SInt32 nranges_minus1;
|
||
|
static CInt64 min;
|
||
|
static CInt64 max;
|
||
|
static CInt64 first;
|
||
|
static short selector_gpr;
|
||
|
static short selector_gprHi;
|
||
|
static Type *selector_type;
|
||
|
static PCodeLabel *defaultlabel;
|
||
|
static CInt64 range;
|
||
|
|
||
|
static void compare_cases() {
|
||
|
}
|
||
|
|
||
|
static void build_case_ranges(Type *type, SwitchCase *cases, CLabel *label) {
|
||
|
}
|
||
|
|
||
|
static void treecompare() {
|
||
|
}
|
||
|
|
||
|
static void I8_treecompare() {
|
||
|
}
|
||
|
|
||
|
static void generate_tree(ENode *expr) {
|
||
|
}
|
||
|
|
||
|
static void create_switch_table() {
|
||
|
}
|
||
|
|
||
|
static void generate_table(ENode *expr, SwitchInfo *info) {
|
||
|
}
|
||
|
|
||
|
void switchstatement(ENode *expr, SwitchInfo *info) {
|
||
|
Boolean use_table;
|
||
|
SwitchCase *swcase;
|
||
|
|
||
|
use_table = copts.switch_tables;
|
||
|
|
||
|
ncases = 0;
|
||
|
for (swcase = info->cases; swcase; swcase = swcase->next) {
|
||
|
if (!swcase->label->pclabel)
|
||
|
swcase->label->pclabel = makepclabel();
|
||
|
ncases++;
|
||
|
}
|
||
|
|
||
|
#line 656
|
||
|
CError_ASSERT(ncases >= 0 && ncases <= 0x3333332);
|
||
|
|
||
|
if (!info->defaultlabel->pclabel)
|
||
|
info->defaultlabel->pclabel = makepclabel();
|
||
|
defaultlabel = info->defaultlabel->pclabel;
|
||
|
|
||
|
build_case_ranges(expr->rtype, info->cases, info->defaultlabel);
|
||
|
|
||
|
if (TYPE_IS_8BYTES(expr->rtype)) {
|
||
|
generate_tree(expr);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!use_table || nranges_minus1 < 8 || (nranges_minus1 * 2) < ((range.lo / 1) + 4))
|
||
|
generate_tree(expr);
|
||
|
else
|
||
|
generate_table(expr, info);
|
||
|
}
|
||
|
|
||
|
void dumpswitchtables(Object *funcobj) {
|
||
|
}
|