-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructionFabric.h
More file actions
38 lines (36 loc) · 1.07 KB
/
InstructionFabric.h
File metadata and controls
38 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <BType.h>
#include <EType.h>
#include <IAddrType.h>
#include <IType.h>
#include <JType.h>
#include <RType.h>
#include <SType.h>
#include <UType.h>
#include <UnknownType.h>
class InstructionFabric {
public:
static Instruction* createInstruction(const uint32_t bits) {
const Type type = Storage::getType(
Instruction::parseOpcodeBits(bits));
if (type == Type::R) {
return new RType(bits);
} else if (type == Type::I) {
return new IType(bits);
} else if (type == Type::IAddr) {
return new IAddrType(bits);
} else if (type == Type::S) {
return new SType(bits);
} else if (type == Type::B) {
return new BType(bits);
} else if (type == Type::U) {
return new UType(bits);
} else if (type == Type::J) {
return new JType(bits);
} else if (type == Type::E) {
return new EType(bits);
} else {
return new UnknownType(bits);
}
}
};