diff options
author | Nathan Binkert <nate@binkert.org> | 2008-12-06 14:18:18 -0800 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2008-12-06 14:18:18 -0800 |
commit | e141cb7441e79b3596c795faf9f47424f26c65e9 (patch) | |
tree | 2d1d03085ab989e884bab73c977cf21a07c40ce0 /src | |
parent | dd788a23c972ec45248ad42e58eaa5141160cff9 (diff) | |
download | gem5-e141cb7441e79b3596c795faf9f47424f26c65e9.tar.xz |
flags: Change naming of functions to be clearer
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/alpha/faults.cc | 2 | ||||
-rw-r--r-- | src/base/flags.hh | 12 | ||||
-rw-r--r-- | src/mem/packet.hh | 42 | ||||
-rw-r--r-- | src/mem/packet_access.hh | 4 | ||||
-rw-r--r-- | src/mem/request.hh | 76 |
5 files changed, 67 insertions, 69 deletions
diff --git a/src/arch/alpha/faults.cc b/src/arch/alpha/faults.cc index e89cf5c64..e93e16711 100644 --- a/src/arch/alpha/faults.cc +++ b/src/arch/alpha/faults.cc @@ -144,7 +144,7 @@ DtbFault::invoke(ThreadContext *tc) // read, like the EV5). The EV6 approach is cleaner and seems to // work with EV5 PAL code, but not the other way around. if (!tc->misspeculating() && - reqFlags.none(Request::VPTE|Request::NO_FAULT)) { + reqFlags.noneSet(Request::VPTE|Request::NO_FAULT)) { // set VA register with faulting address tc->setMiscRegNoEffect(IPR_VA, vaddr); diff --git a/src/base/flags.hh b/src/base/flags.hh index 712b65319..2e0506391 100644 --- a/src/base/flags.hh +++ b/src/base/flags.hh @@ -59,12 +59,12 @@ class Flags return *this; } - bool any() const { return _flags; } - bool any(Type flags) const { return (_flags & flags); } - bool all() const { return !(~_flags); } - bool all(Type flags) const { return (_flags & flags) == flags; } - bool none() const { return _flags == 0; } - bool none(Type flags) const { return (_flags & flags) == 0; } + bool isSet() const { return _flags; } + bool isSet(Type flags) const { return (_flags & flags); } + bool allSet() const { return !(~_flags); } + bool allSet(Type flags) const { return (_flags & flags) == flags; } + bool noneSet() const { return _flags == 0; } + bool noneSet(Type flags) const { return (_flags & flags) == 0; } void clear() { _flags = 0; } void clear(Type flags) { _flags &= ~flags; } void set(Type flags) { _flags |= flags; } diff --git a/src/mem/packet.hh b/src/mem/packet.hh index b75490168..41f599fa0 100644 --- a/src/mem/packet.hh +++ b/src/mem/packet.hh @@ -407,15 +407,15 @@ class Packet : public FastAlloc, public Printable // Snoop flags void assertMemInhibit() { flags.set(MEM_INHIBIT); } - bool memInhibitAsserted() { return flags.any(MEM_INHIBIT); } + bool memInhibitAsserted() { return flags.isSet(MEM_INHIBIT); } void assertShared() { flags.set(SHARED); } - bool sharedAsserted() { return flags.any(SHARED); } + bool sharedAsserted() { return flags.isSet(SHARED); } // Special control flags void setExpressSnoop() { flags.set(EXPRESS_SNOOP); } - bool isExpressSnoop() { return flags.any(EXPRESS_SNOOP); } + bool isExpressSnoop() { return flags.isSet(EXPRESS_SNOOP); } void setSupplyExclusive() { flags.set(SUPPLY_EXCLUSIVE); } - bool isSupplyExclusive() { return flags.any(SUPPLY_EXCLUSIVE); } + bool isSupplyExclusive() { return flags.isSet(SUPPLY_EXCLUSIVE); } // Network error conditions... encapsulate them as methods since // their encoding keeps changing (from result field to command @@ -439,19 +439,19 @@ class Packet : public FastAlloc, public Printable void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; } /// Accessor function to get the source index of the packet. - NodeID getSrc() const { assert(flags.any(VALID_SRC)); return src; } + NodeID getSrc() const { assert(flags.isSet(VALID_SRC)); return src; } /// Accessor function to set the source index of the packet. void setSrc(NodeID _src) { src = _src; flags.set(VALID_SRC); } /// Reset source field, e.g. to retransmit packet on different bus. void clearSrc() { flags.clear(VALID_SRC); } /// Accessor function for the destination index of the packet. - NodeID getDest() const { assert(flags.any(VALID_DST)); return dest; } + NodeID getDest() const { assert(flags.isSet(VALID_DST)); return dest; } /// Accessor function to set the destination index of the packet. void setDest(NodeID _dest) { dest = _dest; flags.set(VALID_DST); } - Addr getAddr() const { assert(flags.all(VALID_ADDR)); return addr; } - int getSize() const { assert(flags.all(VALID_SIZE)); return size; } + Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; } + int getSize() const { assert(flags.isSet(VALID_SIZE)); return size; } Addr getOffset(int blkSize) const { return getAddr() & (Addr)(blkSize - 1); } /** @@ -465,7 +465,7 @@ class Packet : public FastAlloc, public Printable addr(_req->paddr), size(_req->size), dest(_dest), time(curTick), senderState(NULL) { - if (req->flags.any(Request::VALID_PADDR)) + if (req->flags.isSet(Request::VALID_PADDR)) flags.set(VALID_ADDR|VALID_SIZE); } @@ -479,7 +479,7 @@ class Packet : public FastAlloc, public Printable addr(_req->paddr & ~(_blkSize - 1)), size(_blkSize), dest(_dest), time(curTick), senderState(NULL) { - if (req->flags.any(Request::VALID_PADDR)) + if (req->flags.isSet(Request::VALID_PADDR)) flags.set(VALID_ADDR|VALID_SIZE); } @@ -492,7 +492,7 @@ class Packet : public FastAlloc, public Printable */ Packet(Packet *pkt, bool clearFlags = false) : cmd(pkt->cmd), req(pkt->req), - data(pkt->flags.any(STATIC_DATA) ? pkt->data : NULL), + data(pkt->flags.isSet(STATIC_DATA) ? pkt->data : NULL), addr(pkt->addr), size(pkt->size), src(pkt->src), dest(pkt->dest), time(curTick), senderState(pkt->senderState) { @@ -526,7 +526,7 @@ class Packet : public FastAlloc, public Printable void reinitFromRequest() { - assert(req->flags.any(Request::VALID_PADDR)); + assert(req->flags.isSet(Request::VALID_PADDR)); flags = 0; addr = req->paddr; size = req->size; @@ -551,7 +551,7 @@ class Packet : public FastAlloc, public Printable cmd = cmd.responseCommand(); dest = src; - flags.set(VALID_DST, flags.any(VALID_SRC)); + flags.set(VALID_DST, flags.isSet(VALID_SRC)); flags.clear(VALID_SRC); } @@ -590,7 +590,7 @@ class Packet : public FastAlloc, public Printable void dataStatic(T *p) { - assert(flags.none(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); + assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); data = (PacketDataPtr)p; flags.set(STATIC_DATA); } @@ -603,7 +603,7 @@ class Packet : public FastAlloc, public Printable void dataDynamicArray(T *p) { - assert(flags.none(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); + assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); data = (PacketDataPtr)p; flags.set(DYNAMIC_DATA|ARRAY_DATA); } @@ -616,7 +616,7 @@ class Packet : public FastAlloc, public Printable void dataDynamic(T *p) { - assert(flags.none(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); + assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA)); data = (PacketDataPtr)p; flags.set(DYNAMIC_DATA); } @@ -628,7 +628,7 @@ class Packet : public FastAlloc, public Printable T* getPtr() { - assert(flags.any(STATIC_DATA|DYNAMIC_DATA)); + assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); return (T*)data; } @@ -689,9 +689,9 @@ class Packet : public FastAlloc, public Printable void deleteData() { - if (flags.any(ARRAY_DATA)) + if (flags.isSet(ARRAY_DATA)) delete [] data; - else if (flags.any(DYNAMIC_DATA)) + else if (flags.isSet(DYNAMIC_DATA)) delete data; flags.clear(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA); @@ -703,11 +703,11 @@ class Packet : public FastAlloc, public Printable allocate() { if (data) { - assert(flags.any(STATIC_DATA|DYNAMIC_DATA)); + assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); return; } - assert(flags.none(STATIC_DATA|DYNAMIC_DATA)); + assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA)); flags.set(DYNAMIC_DATA|ARRAY_DATA); data = new uint8_t[getSize()]; } diff --git a/src/mem/packet_access.hh b/src/mem/packet_access.hh index 1e233ee57..f70d508b2 100644 --- a/src/mem/packet_access.hh +++ b/src/mem/packet_access.hh @@ -46,7 +46,7 @@ template <typename T> inline T Packet::get() { - assert(flags.any(STATIC_DATA|DYNAMIC_DATA)); + assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); assert(sizeof(T) <= size); return TheISA::gtoh(*(T*)data); } @@ -56,7 +56,7 @@ template <typename T> inline void Packet::set(T v) { - assert(flags.any(STATIC_DATA|DYNAMIC_DATA)); + assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); assert(sizeof(T) <= size); *(T*)data = TheISA::htog(v); } diff --git a/src/mem/request.hh b/src/mem/request.hh index c7cadaa03..f60eb17fa 100644 --- a/src/mem/request.hh +++ b/src/mem/request.hh @@ -230,7 +230,7 @@ class Request : public FastAlloc void setPaddr(Addr _paddr) { - assert(flags.any(VALID_VADDR)); + assert(flags.isSet(VALID_VADDR)); paddr = _paddr; flags.set(VALID_PADDR); } @@ -241,8 +241,8 @@ class Request : public FastAlloc */ void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2) { - assert(flags.any(VALID_VADDR)); - assert(flags.none(VALID_PADDR)); + assert(flags.isSet(VALID_VADDR)); + assert(flags.noneSet(VALID_PADDR)); assert(split_addr > vaddr && split_addr < vaddr + size); req1 = new Request; *req1 = *this; @@ -259,7 +259,7 @@ class Request : public FastAlloc Addr getPaddr() { - assert(flags.any(VALID_PADDR)); + assert(flags.isSet(VALID_PADDR)); return paddr; } @@ -269,7 +269,7 @@ class Request : public FastAlloc int getSize() { - assert(flags.any(VALID_SIZE)); + assert(flags.isSet(VALID_SIZE)); return size; } @@ -277,64 +277,62 @@ class Request : public FastAlloc Tick getTime() { - assert(flags.any(VALID_PADDR|VALID_VADDR)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); return time; } void setTime(Tick when) { - assert(flags.any(VALID_PADDR|VALID_VADDR)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); time = when; } - void resetTime() { setTime(curTick); } - /** Accessor for flags. */ Flags getFlags() { - assert(flags.any(VALID_PADDR|VALID_VADDR)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); return flags & PUBLIC_FLAGS; } Flags anyFlags(Flags _flags) { - assert(flags.any(VALID_PADDR|VALID_VADDR)); - assert(_flags.none(~PUBLIC_FLAGS)); - return flags.any(_flags); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); + assert(_flags.noneSet(~PUBLIC_FLAGS)); + return flags.isSet(_flags); } Flags allFlags(Flags _flags) { - assert(flags.any(VALID_PADDR|VALID_VADDR)); - assert(_flags.none(~PUBLIC_FLAGS)); - return flags.all(_flags); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); + assert(_flags.noneSet(~PUBLIC_FLAGS)); + return flags.allSet(_flags); } /** Accessor for flags. */ void setFlags(Flags _flags) { - assert(flags.any(VALID_PADDR|VALID_VADDR)); - assert(_flags.none(~PUBLIC_FLAGS)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); + assert(_flags.noneSet(~PUBLIC_FLAGS)); flags.set(_flags); } void clearFlags(Flags _flags) { - assert(flags.any(VALID_PADDR|VALID_VADDR)); - assert(_flags.none(~PUBLIC_FLAGS)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); + assert(_flags.noneSet(~PUBLIC_FLAGS)); flags.clear(_flags); } void clearFlags() { - assert(flags.any(VALID_PADDR|VALID_VADDR)); + assert(flags.isSet(VALID_PADDR|VALID_VADDR)); flags.clear(PUBLIC_FLAGS); } @@ -342,7 +340,7 @@ class Request : public FastAlloc Addr getVaddr() { - assert(flags.any(VALID_VADDR)); + assert(flags.isSet(VALID_VADDR)); return vaddr; } @@ -350,7 +348,7 @@ class Request : public FastAlloc int getAsid() { - assert(flags.any(VALID_VADDR)); + assert(flags.isSet(VALID_VADDR)); return asid; } @@ -358,7 +356,7 @@ class Request : public FastAlloc uint8_t getAsi() { - assert(flags.any(VALID_VADDR)); + assert(flags.isSet(VALID_VADDR)); return flags & ASI_BITS; } @@ -366,7 +364,7 @@ class Request : public FastAlloc void setAsi(uint8_t a) { - assert(flags.any(VALID_VADDR)); + assert(flags.isSet(VALID_VADDR)); flags.update(a, ASI_BITS); } @@ -374,8 +372,8 @@ class Request : public FastAlloc bool isMmapedIpr() { - assert(flags.any(VALID_PADDR)); - return flags.any(MMAPED_IPR); + assert(flags.isSet(VALID_PADDR)); + return flags.isSet(MMAPED_IPR); } /** Accessor function for asi.*/ @@ -390,14 +388,14 @@ class Request : public FastAlloc bool extraDataValid() { - return flags.any(VALID_EXTRA_DATA); + return flags.isSet(VALID_EXTRA_DATA); } /** Accessor function for store conditional return value.*/ uint64_t getExtraData() const { - assert(flags.any(VALID_EXTRA_DATA)); + assert(flags.isSet(VALID_EXTRA_DATA)); return extraData; } @@ -413,7 +411,7 @@ class Request : public FastAlloc int contextId() const { - assert(flags.any(VALID_CONTEXT_ID)); + assert(flags.isSet(VALID_CONTEXT_ID)); return _contextId; } @@ -421,7 +419,7 @@ class Request : public FastAlloc int threadId() const { - assert(flags.any(VALID_THREAD_ID)); + assert(flags.isSet(VALID_THREAD_ID)); return _threadId; } @@ -429,27 +427,27 @@ class Request : public FastAlloc Addr getPC() const { - assert(flags.any(VALID_PC)); + assert(flags.isSet(VALID_PC)); return pc; } /** Accessor Function to Check Cacheability. */ - bool isUncacheable() const { return flags.any(UNCACHEABLE); } - bool isInstRead() const { return flags.any(INST_READ); } - bool isLocked() const { return flags.any(LOCKED); } - bool isSwap() const { return flags.any(MEM_SWAP|MEM_SWAP_COND); } - bool isCondSwap() const { return flags.any(MEM_SWAP_COND); } + bool isUncacheable() const { return flags.isSet(UNCACHEABLE); } + bool isInstRead() const { return flags.isSet(INST_READ); } + bool isLocked() const { return flags.isSet(LOCKED); } + bool isSwap() const { return flags.isSet(MEM_SWAP|MEM_SWAP_COND); } + bool isCondSwap() const { return flags.isSet(MEM_SWAP_COND); } bool isMisaligned() const { - if (flags.any(NO_ALIGN_FAULT)) + if (flags.isSet(NO_ALIGN_FAULT)) return false; if ((vaddr & 0x1)) return true; - if (flags.any(NO_HALF_WORD_ALIGN_FAULT)) + if (flags.isSet(NO_HALF_WORD_ALIGN_FAULT)) return false; if ((vaddr & 0x2)) |