Index: src/compiler/machine-operator.h |
diff --git a/src/compiler/machine-operator.h b/src/compiler/machine-operator.h |
index e3a67606765dabd97d9e5c3c40e21032ed8f3be5..166c46f1dfec2cffa4db8f0fd8cd9c23b763c3aa 100644 |
--- a/src/compiler/machine-operator.h |
+++ b/src/compiler/machine-operator.h |
@@ -123,10 +123,73 @@ class MachineOperatorBuilder final : public ZoneObject { |
}; |
typedef base::Flags<Flag, unsigned> Flags; |
+ struct UnalignedAccessConfig { |
titzer
2016/05/06 16:06:47
Can we call this simply AlignmentRequirements?
ivica.bogosavljevic
2016/05/10 08:32:22
Acknowledged.
|
+ public: |
+ explicit UnalignedAccessConfig(bool fullUnalignedAccessSupport, |
+ bool noUnalignedAccessSupport) |
+ : fullUnalignedAccessSupport_(fullUnalignedAccessSupport), |
+ noUnalignedAccessSupport_(noUnalignedAccessSupport), |
+ unalingedLoadSupportedTypes_(NULL, 0), |
+ unalingedStoreSupportedTypes_(NULL, 0) { |
+ DCHECK(fullUnalignedAccessSupport != noUnalignedAccessSupport); |
+ } |
+ explicit UnalignedAccessConfig( |
+ Vector<MachineType> unalingedLoadSupportedTypes, |
+ Vector<MachineType> unalignedStoreSupportedTypes) |
+ : fullUnalignedAccessSupport_(false), |
+ noUnalignedAccessSupport_(false), |
+ unalingedLoadSupportedTypes_(unalingedLoadSupportedTypes), |
+ unalingedStoreSupportedTypes_(unalignedStoreSupportedTypes) {} |
+ |
+ bool IsUnalignedLoadSupported(const MachineType& machineType, |
+ uint8_t alignment) const { |
+ return IsUnalingedSupported(unalingedLoadSupportedTypes_, machineType, |
+ alignment); |
+ } |
+ |
+ bool IsUnalignedStoreSupported(const MachineType& machineType, |
+ uint8_t alignment) const { |
+ return IsUnalingedSupported(unalingedStoreSupportedTypes_, machineType, |
+ alignment); |
+ } |
+ |
+ static UnalignedAccessConfig FullUnalignedAccessSupport() { |
+ return UnalignedAccessConfig(true, false); |
+ } |
+ static UnalignedAccessConfig NoUnalignedAccessSupport() { |
+ return UnalignedAccessConfig(false, true); |
+ } |
+ |
+ private: |
+ bool IsUnalingedSupported(const Vector<MachineType>& supported, |
+ const MachineType& machineType, |
+ uint8_t alignment) const { |
+ if (fullUnalignedAccessSupport_) { |
+ return true; |
+ } else if (noUnalignedAccessSupport_) { |
+ return false; |
+ } else { |
+ for (MachineType m : supported) { |
+ if (m == machineType) { |
+ return true; |
+ } |
+ } |
+ return false; |
+ } |
+ } |
+ |
+ const bool fullUnalignedAccessSupport_; |
+ const bool noUnalignedAccessSupport_; |
+ const Vector<MachineType> unalingedLoadSupportedTypes_; |
+ const Vector<MachineType> unalingedStoreSupportedTypes_; |
+ }; |
+ |
explicit MachineOperatorBuilder( |
Zone* zone, |
MachineRepresentation word = MachineType::PointerRepresentation(), |
- Flags supportedOperators = kNoFlags); |
+ Flags supportedOperators = kNoFlags, |
+ UnalignedAccessConfig unalignedAccessConfig = |
+ UnalignedAccessConfig::NoUnalignedAccessSupport()); |
const Operator* Word32And(); |
const Operator* Word32Or(); |
@@ -511,6 +574,18 @@ class MachineOperatorBuilder final : public ZoneObject { |
bool Is64() const { return word() == MachineRepresentation::kWord64; } |
MachineRepresentation word() const { return word_; } |
+ bool UnalignedLoadSupported(const MachineType& machineType, |
+ uint8_t alignment) { |
+ return unalignedAccessConfig_.IsUnalignedLoadSupported(machineType, |
+ alignment); |
+ } |
+ |
+ bool UnalignedStoreSupported(const MachineType& machineType, |
+ uint8_t alignment) { |
+ return unalignedAccessConfig_.IsUnalignedStoreSupported(machineType, |
+ alignment); |
+ } |
+ |
// Pseudo operators that translate to 32/64-bit operators depending on the |
// word-size of the target machine assumed by this builder. |
#define PSEUDO_OP_LIST(V) \ |
@@ -545,6 +620,7 @@ class MachineOperatorBuilder final : public ZoneObject { |
MachineOperatorGlobalCache const& cache_; |
MachineRepresentation const word_; |
Flags const flags_; |
+ UnalignedAccessConfig const unalignedAccessConfig_; |
DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
}; |