5
5
#include " sparta/memory/AddressTypes.hpp"
6
6
#include " sparta/resources/Scoreboard.hpp"
7
7
#include " sparta/resources/Queue.hpp"
8
+ #include " sparta/resources/Buffer.hpp"
8
9
#include " sparta/pairs/SpartaKeyPairs.hpp"
9
10
#include " sparta/simulation/State.hpp"
10
11
#include " sparta/utils/SpartaSharedPointer.hpp"
17
18
#include " CoreTypes.hpp"
18
19
#include " vector/VectorConfig.hpp"
19
20
#include " MiscUtils.hpp"
21
+ #include " rename/RenameData.hpp"
20
22
21
23
#include < cstdint>
22
24
#include < cstdlib>
@@ -38,47 +40,12 @@ namespace olympia
38
40
class Inst
39
41
{
40
42
public:
41
- class RenameData
42
- {
43
- public:
44
- // A register consists of its value and its register file.
45
- struct Reg
46
- {
47
- uint32_t val = 0 ;
48
- core_types::RegFile rf = core_types::RegFile::RF_INVALID;
49
- mavis::InstMetaData::OperandFieldID field_id =
50
- mavis::InstMetaData::OperandFieldID::NONE;
51
- bool is_x0 = false ;
52
- };
53
-
54
- using RegList = std::vector<Reg>;
55
-
56
- void setOriginalDestination (const Reg & destination) { original_dest_ = destination; }
57
-
58
- void setDestination (const Reg & destination) { dest_ = destination; }
59
-
60
- void setDataReg (const Reg & data_reg) { data_reg_ = data_reg; }
61
-
62
- void setSource (const Reg & source) { src_.emplace_back (source); }
63
-
64
- const RegList & getSourceList () const { return src_; }
65
-
66
- const Reg & getOriginalDestination () const { return original_dest_; }
67
-
68
- const Reg & getDestination () const { return dest_; }
69
-
70
- const Reg & getDataReg () const { return data_reg_; }
71
-
72
- private:
73
- Reg original_dest_;
74
- Reg dest_;
75
- RegList src_;
76
- Reg data_reg_;
77
- };
78
-
79
43
// Used by Mavis
80
44
using PtrType = sparta::SpartaSharedPointer<Inst>;
81
45
46
+ // Used by Rename, etc
47
+ using WeakPtrType = sparta::SpartaWeakPointer<Inst>;
48
+
82
49
// The modeler needs to alias a type called
83
50
// "SpartaPairDefinitionType" to the Pair Definition class of
84
51
// itself
@@ -229,12 +196,9 @@ namespace olympia
229
196
230
197
bool hasTail () const { return has_tail_; }
231
198
232
- void setUOpParent (sparta::SpartaWeakPointer<olympia::Inst> & parent_uop)
233
- {
234
- parent_uop_ = parent_uop;
235
- }
199
+ void setUOpParent (WeakPtrType & parent_uop) { parent_uop_ = parent_uop; }
236
200
237
- sparta::SpartaWeakPointer<olympia::Inst> getUOpParent () { return parent_uop_; }
201
+ WeakPtrType getUOpParent () { return parent_uop_; }
238
202
239
203
// Branch instruction was taken (always set for JAL/JALR)
240
204
void setTakenBranch (bool taken) { is_taken_branch_ = taken; }
@@ -252,6 +216,14 @@ namespace olympia
252
216
253
217
bool isLastInFetchBlock () const { return last_in_fetch_block_; }
254
218
219
+ // ROB target information
220
+ void setTargetROB (bool tgt = true ) { rob_targeted_ = tgt; }
221
+
222
+ bool isTargetROB () const
223
+ {
224
+ return rob_targeted_;
225
+ }
226
+
255
227
// Opcode information
256
228
std::string getMnemonic () const { return opcode_info_->getMnemonic (); }
257
229
@@ -272,7 +244,20 @@ namespace olympia
272
244
return opcode_info_->getSourceOpInfoList ();
273
245
}
274
246
275
- const OpInfoList & getDestOpInfoList () const { return opcode_info_->getDestOpInfoList (); }
247
+ const OpInfoList & getDestOpInfoList () const
248
+ {
249
+ return opcode_info_->getDestOpInfoList ();
250
+ }
251
+
252
+ const RenameData::DestOpInfoWithRegfileList & getDestOpInfoListWithRegfile () const
253
+ {
254
+ return dest_opcode_info_with_reg_file_;
255
+ }
256
+
257
+ const RenameData::SrcOpInfoWithRegfileList & getSrcOpInfoListWithRegfile () const
258
+ {
259
+ return src_opcode_info_with_reg_file_;
260
+ }
276
261
277
262
bool hasZeroRegSource () const
278
263
{
@@ -284,7 +269,7 @@ namespace olympia
284
269
bool hasZeroRegDest () const
285
270
{
286
271
return std::any_of (getDestOpInfoList ().begin (), getDestOpInfoList ().end (),
287
- [](const mavis::OperandInfo::Element & elem)
272
+ [](const auto & elem)
288
273
{ return elem.field_value == 0 ; });
289
274
}
290
275
@@ -318,9 +303,57 @@ namespace olympia
318
303
}
319
304
}
320
305
306
+ void setDataRegister (RenameData::Reg && reg)
307
+ {
308
+ if (!reg.op_info .is_x0 )
309
+ {
310
+ getDataRegisterBitMask (reg.op_info .reg_file ).set (reg.phys_reg );
311
+ }
312
+ getRenameData ().setDataReg (std::forward<RenameData::Reg>(reg));
313
+ }
314
+
315
+ void setDestRegisterBitWithScoreboardUpdate (const RenameData::Reg & reg,
316
+ sparta::Scoreboard* const scoreboard)
317
+ {
318
+ auto & bitmask = getDestRegisterBitMask (reg.op_info .reg_file );
319
+ bitmask.set (reg.phys_reg );
320
+
321
+ // clear scoreboard for the PRF we are allocating
322
+ scoreboard->clearBits (bitmask);
323
+ }
324
+
325
+ void addDestRegister (RenameData::Reg && reg)
326
+ {
327
+ getRenameData ().addDestination (std::forward<RenameData::Reg>(reg));
328
+ }
329
+
330
+ void addDestRegisterWithScoreboardUpdate (RenameData::Reg && reg,
331
+ sparta::Scoreboard* const scoreboard)
332
+ {
333
+ if (!reg.op_info .is_x0 )
334
+ {
335
+ setDestRegisterBitWithScoreboardUpdate (reg, scoreboard);
336
+ }
337
+
338
+ addDestRegister (std::forward<RenameData::Reg>(reg));
339
+ }
340
+
341
+ void addSrcRegister (RenameData::Reg && reg)
342
+ {
343
+ if (!reg.op_info .is_x0 )
344
+ {
345
+ getSrcRegisterBitMask (reg.op_info .reg_file ).set (reg.phys_reg );
346
+ }
347
+
348
+ getRenameData ().addSource (std::forward<RenameData::Reg>(reg));
349
+ }
350
+
351
+
321
352
// Static instruction information
322
353
bool isStoreInst () const { return is_store_; }
323
354
355
+ bool isLoadInst () const { return is_load_; }
356
+
324
357
bool isLoadStoreInst () const { return inst_arch_info_->isLoadStore (); }
325
358
326
359
uint32_t getExecuteTime () const { return inst_arch_info_->getExecutionTime (); }
@@ -357,6 +390,14 @@ namespace olympia
357
390
358
391
bool isCoF () const { return is_cof_; }
359
392
393
+ bool isMove () const { return is_move_; }
394
+
395
+ // Is a load the producer for one or more of this inst's operands?
396
+ bool hasLoadProducer () const { return has_load_producer_; }
397
+
398
+ // This instruction is fed by a load
399
+ void setLoadProducer (bool load_producer) { has_load_producer_ = load_producer; }
400
+
360
401
// Rename information
361
402
core_types::RegisterBitMask & getSrcRegisterBitMask (const core_types::RegFile rf)
362
403
{
@@ -433,6 +474,11 @@ namespace olympia
433
474
mavis::OpcodeInfo::PtrType opcode_info_;
434
475
InstArchInfo::PtrType inst_arch_info_;
435
476
477
+ // Handy list that extends Mavis' opcode info with register
478
+ // file type.
479
+ RenameData::DestOpInfoWithRegfileList dest_opcode_info_with_reg_file_;
480
+ RenameData::SrcOpInfoWithRegfileList src_opcode_info_with_reg_file_;
481
+
436
482
sparta::memory::addr_t inst_pc_ = 0 ; // Instruction's PC
437
483
sparta::memory::addr_t target_vaddr_ =
438
484
0 ; // Instruction's Target PC (for branches, loads/stores)
@@ -443,6 +489,8 @@ namespace olympia
443
489
uint64_t program_id_increment_ = 1 ;
444
490
bool is_speculative_ = false ; // Is this instruction soon to be flushed?
445
491
const bool is_store_;
492
+ const bool is_load_;
493
+ const bool is_move_;
446
494
const bool is_transfer_; // Is this a transfer instruction (F2I/I2F)
447
495
const bool is_branch_;
448
496
const bool is_condbranch_;
@@ -453,6 +501,11 @@ namespace olympia
453
501
bool is_cof_ = false ;
454
502
const bool has_immediate_;
455
503
504
+ // Is this instruction just retired? (Dynamically assigned)
505
+ bool rob_targeted_ = false ;
506
+
507
+ bool has_load_producer_ = false ;
508
+
456
509
// Vector
457
510
const bool is_vector_;
458
511
const bool is_vector_whole_reg_;
@@ -489,7 +542,9 @@ namespace olympia
489
542
};
490
543
491
544
using InstPtr = Inst::PtrType;
545
+ using InstWeakPtr = Inst::WeakPtrType;
492
546
using InstQueue = sparta::Queue<InstPtr>;
547
+ using InstBuffer = sparta::Buffer<InstPtr>;
493
548
494
549
inline std::ostream & operator <<(std::ostream & os, const Inst::Status & status)
495
550
{
0 commit comments