Deleted Added
sdiff udiff text old ( 10627:63edd4a1243f ) new ( 10771:ea35886cd847 )
full compact
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 43 unchanged lines hidden (view full) ---

54 : QueuedPrefetcher(p),
55 maxConf(p->max_conf),
56 threshConf(p->thresh_conf),
57 minConf(p->min_conf),
58 startConf(p->start_conf),
59 pcTableAssoc(p->table_assoc),
60 pcTableSets(p->table_sets),
61 useMasterId(p->use_master_id),
62 degree(p->degree),
63 pcTable(pcTableAssoc, pcTableSets, name())
64{
65 // Don't consult stride prefetcher on instruction accesses
66 onInst = false;
67
68 assert(isPowerOf2(pcTableSets));
69}
70
71StridePrefetcher::StrideEntry**
72StridePrefetcher::PCTable::allocateNewContext(int context)
73{
74 auto res = entries.insert(std::make_pair(context,
75 new StrideEntry*[pcTableSets]));
76 auto it = res.first;
77 chatty_assert(res.second, "Allocating an already created context\n");
78 assert(it->first == context);
79
80 DPRINTF(HWPrefetch, "Adding context %i with stride entries at %p\n",
81 context, it->second);
82
83 StrideEntry** entry = it->second;
84 for (int s = 0; s < pcTableSets; s++) {
85 entry[s] = new StrideEntry[pcTableAssoc];
86 }
87 return entry;
88}
89
90StridePrefetcher::PCTable::~PCTable() {
91 for (auto entry : entries) {
92 for (int s = 0; s < pcTableSets; s++) {
93 delete[] entry.second[s];
94 }
95 delete[] entry.second;
96 }
97}
98
99void
100StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
101 std::vector<Addr> &addresses)
102{
103 if (!pkt->req->hasPC()) {
104 DPRINTF(HWPrefetch, "Ignoring request with no PC.\n");
105 return;
106 }
107
108 // Get required packet info
109 Addr pkt_addr = pkt->getAddr();
110 Addr pc = pkt->req->getPC();
111 bool is_secure = pkt->isSecure();
112 MasterID master_id = useMasterId ? pkt->req->masterId() : 0;
113
114 // Lookup pc-based information
115 StrideEntry *entry;
116
117 if(pcTableHit(pc, is_secure, master_id, entry)) {
118 // Hit in table
119 int new_stride = pkt_addr - entry->lastAddr;
120 bool stride_match = (new_stride == entry->stride);
121

--- 98 unchanged lines hidden ---