| ... | @@ -11,9 +11,6 @@ const std = @import("std"); | ... | @@ -11,9 +11,6 @@ const std = @import("std"); |
| 11 | const Allocator = std.mem.Allocator; | 11 | const Allocator = std.mem.Allocator; |
| 12 | const assert = std.debug.assert; | 12 | const assert = std.debug.assert; |
| 13 | | 13 | |
| 14 | const ZigModule = @import("../../Module.zig"); | | |
| 15 | const ZigDecl = ZigModule.Decl; | | |
| 16 | | | |
| 17 | const spec = @import("spec.zig"); | 14 | const spec = @import("spec.zig"); |
| 18 | const Word = spec.Word; | 15 | const Word = spec.Word; |
| 19 | const IdRef = spec.IdRef; | 16 | const IdRef = spec.IdRef; |
| ... | @@ -147,7 +144,7 @@ next_result_id: Word, | ... | @@ -147,7 +144,7 @@ next_result_id: Word, |
| 147 | /// Cache for results of OpString instructions for module file names fed to OpSource. | 144 | /// Cache for results of OpString instructions for module file names fed to OpSource. |
| 148 | /// Since OpString is pretty much only used for those, we don't need to keep track of all strings, | 145 | /// Since OpString is pretty much only used for those, we don't need to keep track of all strings, |
| 149 | /// just the ones for OpLine. Note that OpLine needs the result of OpString, and not that of OpSource. | 146 | /// just the ones for OpLine. Note that OpLine needs the result of OpString, and not that of OpSource. |
| 150 | source_file_names: std.StringHashMapUnmanaged(IdRef) = .{}, | 147 | source_file_names: std.AutoArrayHashMapUnmanaged(CacheString, IdRef) = .{}, |
| 151 | | 148 | |
| 152 | /// SPIR-V type- and constant cache. This structure is used to store information about these in a more | 149 | /// SPIR-V type- and constant cache. This structure is used to store information about these in a more |
| 153 | /// efficient manner. | 150 | /// efficient manner. |
| ... | @@ -460,9 +457,9 @@ pub fn addFunction(self: *Module, decl_index: Decl.Index, func: Fn) !void { | ... | @@ -460,9 +457,9 @@ pub fn addFunction(self: *Module, decl_index: Decl.Index, func: Fn) !void { |
| 460 | /// Fetch the result-id of an OpString instruction that encodes the path of the source | 457 | /// Fetch the result-id of an OpString instruction that encodes the path of the source |
| 461 | /// file of the decl. This function may also emit an OpSource with source-level information regarding | 458 | /// file of the decl. This function may also emit an OpSource with source-level information regarding |
| 462 | /// the decl. | 459 | /// the decl. |
| 463 | pub fn resolveSourceFileName(self: *Module, zig_module: *ZigModule, zig_decl: *ZigDecl) !IdRef { | 460 | pub fn resolveSourceFileName(self: *Module, path: []const u8) !IdRef { |
| 464 | const path = zig_decl.getFileScope(zig_module).sub_file_path; | 461 | const path_ref = try self.resolveString(path); |
| 465 | const result = try self.source_file_names.getOrPut(self.gpa, path); | 462 | const result = try self.source_file_names.getOrPut(self.gpa, path_ref); |
| 466 | if (!result.found_existing) { | 463 | if (!result.found_existing) { |
| 467 | const file_result_id = self.allocId(); | 464 | const file_result_id = self.allocId(); |
| 468 | result.value_ptr.* = file_result_id; | 465 | result.value_ptr.* = file_result_id; |