示例#1
0
        public static void EnableRiscvOpcodesCounting(this BaseRiscV cpu, BaseRiscV.InstructionSet instructionSet)
        {
            Dictionary <BaseRiscV.InstructionSet, IEnumerable <string> > map = null;

            if (cpu.Architecture == "riscv")
            {
                map = opcodesFilesMap32;
            }
            else if (cpu.Architecture == "riscv64")
            {
                map = opcodesFilesMap64;
            }
            else
            {
                throw new RecoverableException($"Unsupported CPU type: {cpu.GetType()}");
            }

            if (!map.TryGetValue(instructionSet, out var resourceNames))
            {
                throw new RecoverableException($"Opcodes counting for the {instructionSet} extension not supported");
            }

            foreach (var resourceName in resourceNames)
            {
                var assembly = Assembly.GetExecutingAssembly();
                if (!assembly.TryFromResourceToTemporaryFile(resourceName, out var file))
                {
                    throw new RecoverableException($"Couldn't load the {resourceName} resource - this might indicate a broken compilation");
                }

                cpu.EnableRiscvOpcodesCounting(file);
            }
        }
示例#2
0
 public static void EnableRiscvOpcodesCounting(this BaseRiscV cpu)
 {
     foreach (var set in cpu.ArchitectureSets)
     {
         cpu.EnableRiscvOpcodesCounting(set);
     }
 }
示例#3
0
        public static void EnableRiscvOpcodesCounting(this BaseRiscV cpu, ReadFilePath file)
        {
            foreach (var x in RiscVOpcodesParser.Parse(file))
            {
                cpu.InstallOpcodeCounterPattern(x.Item1, x.Item2);
            }

            cpu.EnableOpcodesCounting = true;
        }
示例#4
0
        public static void EnableRiscvOpcodesCountingFromEmbeddedResource(this BaseRiscV cpu, string name)
        {
            var assembly = Assembly.GetExecutingAssembly();

            if (!assembly.TryFromResourceToTemporaryFile($"{ResourceNamePrefix}.{name}", out var file))
            {
                var availableResources = string.Join("\n", cpu.GetRiscvOpcodesEmbeddedResourceNames());
                throw new RecoverableException($"Couldn't load the {name} resource - please choose from:\n{availableResources}");
            }
            cpu.EnableRiscvOpcodesCounting(file);
        }
示例#5
0
        public static IEnumerable <string> GetRiscvOpcodesEmbeddedResourceNames(this BaseRiscV cpu)
        {
            var assembly = Assembly.GetExecutingAssembly();

            return(assembly.GetManifestResourceNames().Where(x => x.StartsWith(ResourceNamePrefix)).Select(x => x.Substring(ResourceNamePrefix.Length + 1)));
        }
 public static void EnableVectorOpcodesCounting(this BaseRiscV cpu)
 {
     cpu.EnableRiscvOpcodesCounting(BaseRiscV.InstructionSet.V);
 }