An employee works on a Ford Motor Co. Super Duty Truck engine at the Ford Kentucky Truck Plant in Louisville, Kentucky, Sept. 30, 2016.

Automotive companies have the most to lose if the U.S. imposes tariffs on Mexican goods, with consumer staples, materials and energy companies trailing closely behind, RBC Capital Markets said in a note Thursday.

With over $100 billion worth of autos and auto parts imported into the U.S. from Mexico, General Motors, Ford, American Axel, Autoliv and Lear are the stocks most at risk, RBC head of U.S. equity strategy Lori Calvasina said.

President Donald Trump threatened on May 30 to impose a 5% tariff on all Mexican imports starting Monday unless Mexico does more to stop illegal immigration into the U.S. The tariffs would go up incrementally to 25% by October.

While RBC acknowledged China tariffs posed a greater risk to U.S. companies than tariffs on Mexican goods, the firm examined which sectors in the U.S. equity market could be hit in a trade war with Mexico.

"The new Mexico tariffs could be devastating to the entire auto value chain," Calvasina said.

Companies like Advanced Auto Parts, Autozone, and O'Reilly Autoparts have scores reflecting "negative" impact because they will likely have to pass price increases onto the consumer, she said.

Within the consumer staples sector, Spectrum Brands and Newell Brands have the most exposure to Mexico. High demand staples like Constellation Brands may need to front-load shipments ahead of the tariffs, Calvasina said.

RBC's building products sector, which includes companies like Whirlpool and Fortune Brands, will also be impacted negatively, RBC said. Chemicals companies LyondellBasell and Huntsman would be in trouble if Mexico puts retaliatory tariffs on the U.S.

Within the energy sector, ExxonMobile, Shell, Chevron are at risk because of their refining presence in the Gulf of Mexico. A potential 5% tariff on refiners like Marathon Petroleum and Valero could easily eliminate most of the companies' margins, Calvasina said.

She added that RBC views "Utilities, REITs, Tech, Communication Services, Financials, and Health Care as most insulated."

RBC continues to expect that the S&P 500 will reach correction territory over the summer, down 10% from its April highs.

WATCH: Mexico tariffs could be devastating for autos, expert says