MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / CheckLegacySegmentRead

Method CheckLegacySegmentRead

FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp:4035–4077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4033
4034
4035void OpDispatchBuilder::CheckLegacySegmentRead(Ref NewNode, uint32_t SegmentReg) {
4036#ifndef FEX_DISABLE_TELEMETRY
4037 if (SegmentReg == FEXCore::X86Tables::DecodeFlags::FLAG_FS_PREFIX || SegmentReg == FEXCore::X86Tables::DecodeFlags::FLAG_GS_PREFIX) {
4038 // FS and GS segments aren't considered legacy.
4039 return;
4040 }
4041
4042 if (!(SegmentsNeedReadCheck & SegmentReg)) {
4043 // If the block has done multiple reads of a segment register then skip redundant read checks.
4044 // Segment write will cause another read check.
4045 return;
4046 }
4047
4048 if (CTX->Config.DisableTelemetry()) {
4049 // Telemetry disabled at runtime.
4050 return;
4051 }
4052
4053 FEXCore::Telemetry::TelemetryType TelemIndex {};
4054 switch (SegmentReg) {
4055 case FEXCore::X86Tables::DecodeFlags::FLAG_ES_PREFIX:
4056 TelemIndex = FEXCore::Telemetry::TelemetryType::TYPE_WRITES_32BIT_SEGMENT_ES;
4057 SegmentsNeedReadCheck &= ~FEXCore::X86Tables::DecodeFlags::FLAG_ES_PREFIX;
4058 break;
4059 case FEXCore::X86Tables::DecodeFlags::FLAG_CS_PREFIX:
4060 TelemIndex = FEXCore::Telemetry::TelemetryType::TYPE_WRITES_32BIT_SEGMENT_CS;
4061 SegmentsNeedReadCheck &= ~FEXCore::X86Tables::DecodeFlags::FLAG_CS_PREFIX;
4062 break;
4063 case FEXCore::X86Tables::DecodeFlags::FLAG_SS_PREFIX:
4064 TelemIndex = FEXCore::Telemetry::TelemetryType::TYPE_WRITES_32BIT_SEGMENT_SS;
4065 SegmentsNeedReadCheck &= ~FEXCore::X86Tables::DecodeFlags::FLAG_SS_PREFIX;
4066 break;
4067 case FEXCore::X86Tables::DecodeFlags::FLAG_DS_PREFIX:
4068 TelemIndex = FEXCore::Telemetry::TelemetryType::TYPE_WRITES_32BIT_SEGMENT_DS;
4069 SegmentsNeedReadCheck &= ~FEXCore::X86Tables::DecodeFlags::FLAG_DS_PREFIX;
4070 break;
4071 default: FEX_UNREACHABLE;
4072 }
4073
4074 // Will set the telemetry value if NewNode is != 0
4075 _TelemetrySetValue(NewNode, TelemIndex);
4076#endif
4077}
4078
4079void OpDispatchBuilder::CheckLegacySegmentWrite(Ref NewNode, uint32_t SegmentReg) {
4080#ifndef FEX_DISABLE_TELEMETRY

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected