mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[CodeGen] Add iterator_range for the MVT::SimpleValueType enum.
This commit adds a simple iterator over that enum, and a few functions to create iterator ranges over the most common types. Differential Revision: http://reviews.llvm.org/D6537 llvm-svn: 225387
This commit is contained in:
parent
421932bbc2
commit
b2dd8c04fd
@ -15,6 +15,7 @@
|
||||
#ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H
|
||||
#define LLVM_CODEGEN_MACHINEVALUETYPE_H
|
||||
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
@ -576,6 +577,52 @@ namespace llvm {
|
||||
/// returned as Other, otherwise they are invalid.
|
||||
static MVT getVT(Type *Ty, bool HandleUnknown = false);
|
||||
|
||||
private:
|
||||
/// A simple iterator over the MVT::SimpleValueType enum.
|
||||
struct mvt_iterator {
|
||||
SimpleValueType VT;
|
||||
mvt_iterator(SimpleValueType VT) : VT(VT) {}
|
||||
MVT operator*() const { return VT; }
|
||||
bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
|
||||
mvt_iterator& operator++() {
|
||||
VT = (MVT::SimpleValueType)((int)VT + 1);
|
||||
assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
|
||||
"MVT iterator overflowed.");
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
/// A range of the MVT::SimpleValueType enum.
|
||||
typedef iterator_range<mvt_iterator> mvt_range;
|
||||
|
||||
public:
|
||||
/// SimpleValueType Iteration
|
||||
/// @{
|
||||
static mvt_range all_valuetypes() {
|
||||
return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE);
|
||||
}
|
||||
static mvt_range integer_valuetypes() {
|
||||
return mvt_range(MVT::FIRST_INTEGER_VALUETYPE,
|
||||
(MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1));
|
||||
}
|
||||
static mvt_range fp_valuetypes() {
|
||||
return mvt_range(MVT::FIRST_FP_VALUETYPE,
|
||||
(MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1));
|
||||
}
|
||||
static mvt_range vector_valuetypes() {
|
||||
return mvt_range(MVT::FIRST_VECTOR_VALUETYPE,
|
||||
(MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1));
|
||||
}
|
||||
static mvt_range integer_vector_valuetypes() {
|
||||
return mvt_range(
|
||||
MVT::FIRST_INTEGER_VECTOR_VALUETYPE,
|
||||
(MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1));
|
||||
}
|
||||
static mvt_range fp_vector_valuetypes() {
|
||||
return mvt_range(
|
||||
MVT::FIRST_FP_VECTOR_VALUETYPE,
|
||||
(MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1));
|
||||
}
|
||||
/// @}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
Loading…
Reference in New Issue
Block a user