mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Add instructions to fold unary and binary instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3596366bed
commit
6bb09d96a0
@ -36,6 +36,7 @@
|
||||
#define LLVM_OPT_CONSTANTHANDLING_H
|
||||
|
||||
#include "llvm/ConstPoolVals.h"
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/Type.h"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -142,4 +143,35 @@ inline ConstPoolBool *operator<=(const ConstPoolVal &V1,
|
||||
return Result; // !(V1 > V2)
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Implement higher level instruction folding type instructions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Not: return !*V;
|
||||
case Instruction::Neg: return -*V;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V1,
|
||||
ConstPoolVal *V2) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Add: return *V1 + *V2;
|
||||
case Instruction::Sub: return *V1 - *V2;
|
||||
|
||||
case Instruction::SetEQ: return *V1 == *V2;
|
||||
case Instruction::SetNE: return *V1 != *V2;
|
||||
case Instruction::SetLE: return *V1 <= *V2;
|
||||
case Instruction::SetGE: return *V1 >= *V2;
|
||||
case Instruction::SetLT: return *V1 < *V2;
|
||||
case Instruction::SetGT: return *V1 > *V2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define LLVM_OPT_CONSTANTHANDLING_H
|
||||
|
||||
#include "llvm/ConstPoolVals.h"
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/Type.h"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -142,4 +143,35 @@ inline ConstPoolBool *operator<=(const ConstPoolVal &V1,
|
||||
return Result; // !(V1 > V2)
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Implement higher level instruction folding type instructions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Not: return !*V;
|
||||
case Instruction::Neg: return -*V;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V1,
|
||||
ConstPoolVal *V2) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Add: return *V1 + *V2;
|
||||
case Instruction::Sub: return *V1 - *V2;
|
||||
|
||||
case Instruction::SetEQ: return *V1 == *V2;
|
||||
case Instruction::SetNE: return *V1 != *V2;
|
||||
case Instruction::SetLE: return *V1 <= *V2;
|
||||
case Instruction::SetGE: return *V1 >= *V2;
|
||||
case Instruction::SetLT: return *V1 < *V2;
|
||||
case Instruction::SetGT: return *V1 > *V2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define LLVM_OPT_CONSTANTHANDLING_H
|
||||
|
||||
#include "llvm/ConstPoolVals.h"
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/Type.h"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -142,4 +143,35 @@ inline ConstPoolBool *operator<=(const ConstPoolVal &V1,
|
||||
return Result; // !(V1 > V2)
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Implement higher level instruction folding type instructions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Not: return !*V;
|
||||
case Instruction::Neg: return -*V;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
ConstPoolVal *V1,
|
||||
ConstPoolVal *V2) {
|
||||
switch (Opcode) {
|
||||
case Instruction::Add: return *V1 + *V2;
|
||||
case Instruction::Sub: return *V1 - *V2;
|
||||
|
||||
case Instruction::SetEQ: return *V1 == *V2;
|
||||
case Instruction::SetNE: return *V1 != *V2;
|
||||
case Instruction::SetLE: return *V1 <= *V2;
|
||||
case Instruction::SetGE: return *V1 >= *V2;
|
||||
case Instruction::SetLT: return *V1 < *V2;
|
||||
case Instruction::SetGT: return *V1 > *V2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user