🤖 AI Summary
Traditional compiler-based translation requires building a dedicated translator for each language pair, leading to exponential growth in complexity. This work proposes CrossGL—a unified intermediate representation (IR) supporting multi-paradigm semantic expression—and a modular, bidirectional translation system enabling efficient conversion among GPU compute languages including CUDA, HIP, and Metal. The pipeline performs lexical and syntactic analysis to generate an abstract syntax tree (AST), then employs a ToCrossGLConverter for frontend lowering and CodeGen for backend emission, integrating tools such as Slang into a complete compilation flow. CrossGL drastically reduces the engineering overhead of onboarding new languages and enables “write once, deploy anywhere” across heterogeneous GPU platforms. Experimental evaluation confirms successful compilation and correct execution across all supported backends in GPU computing, graphics rendering, and systems programming scenarios, advancing language-agnostic programming.
📝 Abstract
We present CrossTL, a universal programming language translator enabling bidirectional translation between multiple languages through a unified intermediate representation called CrossGL. Traditional approaches require separate translators for each language pair, leading to exponential complexity growth. CrossTL uses a single universal IR to facilitate translations between CUDA, HIP, Metal, DirectX HLSL, OpenGL GLSL, Vulkan SPIR-V, Rust, and Mojo, with Slang support in development. Our system consists of: language-specific lexers/parsers converting source code to ASTs, bidirectional CrossGL translation modules implementing ToCrossGLConverter classes for importing code and CodeGen classes for target generation, and comprehensive backend implementations handling full translation pipelines. We demonstrate effectiveness through comprehensive evaluation across programming domains, achieving successful compilation and execution across all supported backends. The universal IR design enables adding new languages with minimal effort, requiring only language-specific frontend/backend components. Our contributions include: (1) a unified IR capturing semantics of multiple programming paradigms, (2) a modular architecture enabling extensibility, (3) a comprehensive framework supporting GPU compute, graphics programming, and systems languages, and (4) empirical validation demonstrating practical viability of universal code translation. CrossTL represents a significant step toward language-agnostic programming, enabling write-once, deploy-everywhere development.